C
Chris
Guest
I loved the functions that allowed you to create objects dynamically. They've been obsolete for a long time, but I think that they could still be valuable if ever reimplemented. Being able to dynamically create objects made it easier to make GML extendable, simply by having a programatic way to access events through dynamic events.
One such use case would be a wrapper script for async functions that allowed you to supply a callback parameter. Something like this:
Even if we can't dynamically create objects, it would be nice to have access to events programmatically maybe in some other ways.
Is this something that's been considered for the future of GML? Or maybe some other extendable features? Maybe I'm just trying to use GML too much like JavaScript.
One such use case would be a wrapper script for async functions that allowed you to supply a callback parameter. Something like this:
Code:
///showMessageAsync(msg, callback)
//msg (string) - Message to display
//callback (string) - Script name as a string (without parentheses)
//Get arguments
var scr = argument1;
//Dynamically create an object
var callbackObj = object_add();
//Add the message
object_event_add(callbackObj, ev_create, 0, "msg = show_message_async(" + argument0 + ");");
//Setup the callback (note that ev_async and ev_dialog do not exist, but they should!
object_event_add(callbackObj, ev_async, ev_dialog,"
if (ds_map_find_value(async_load, "id") == msg) {
if ds_map_find_value(async_load, "status") {
script_execute(" + scr + ");
instance_destroy();
object_delete(id);
}
}
");
//Add the object to the room
instance_create(0,0,callbackObj);
Even if we can't dynamically create objects, it would be nice to have access to events programmatically maybe in some other ways.
Is this something that's been considered for the future of GML? Or maybe some other extendable features? Maybe I'm just trying to use GML too much like JavaScript.