BoB3k
Member
I love the new structs and methods -- OO in GMS2 at last.
I just thought I would share a trick i just figured out and people can say, cool neat, or tell me that there's a better way to do it--
I have a scripting engine inside of my game engine for custom actions from within game. I began to use script_execute a lot to just call actual GMS2 scripts by name.
But now with the new methods and the ability to create object methods just like real OO, I still wanted to call them by name.
So say you have a GM Object Guy with
do_stuff = function( thing ){ ... }
defined in its Create event.
You can call it with guy.do_stuff( "a_stuff" ); from within code and it's all oo and fun.
Now, how do you call that by name like you can with script_execute?
Like this:
Cool.
I just thought I would share a trick i just figured out and people can say, cool neat, or tell me that there's a better way to do it--
I have a scripting engine inside of my game engine for custom actions from within game. I began to use script_execute a lot to just call actual GMS2 scripts by name.
But now with the new methods and the ability to create object methods just like real OO, I still wanted to call them by name.
So say you have a GM Object Guy with
do_stuff = function( thing ){ ... }
defined in its Create event.
You can call it with guy.do_stuff( "a_stuff" ); from within code and it's all oo and fun.
Now, how do you call that by name like you can with script_execute?
Like this:
Code:
// guy is an instance of Guy
var method_name = "do_stuff";
var the_method = variable_instance_get( guy, method_name );
with( guy ){ the_method( "a_stuff" ); }
Cool.