There are times that you may want to pass a script to an instance in a dynamic way, and for these cases we provide the script_execute function. It will run a user created script resource and pass the given arguments into it. For more information about scripts, see The Script Editor. If the script has a return value, then this function will also return that value when called.
script_execute(scr, arg0, arg1, arg2..., etc...);
Argument | Description |
---|---|
scr | the name of the script that you want to call |
arg0, arg1, arg2..., etc... | The different arguments that you want to pass through to the script |
Will depend on the return value from the script being called
script_execute(choose(scr_Up, scr_Down, scr_Left,
scr_Right), irandom(5));
The above example code will use script_execute to choose one of four user created script resources (in this case related to movement) and pass a random integer to it as argument0.