script_execute

Execute the script with index scr with the given arguments

Syntax:

GML Code Example

script_execute(scr, arg0, arg1, arg2, ...);


Argument Description
scr the name of the script that you want to call
arg0 ... arg14 The different arguments that you want to pass through to the script


Returns: N/A ( see below for more details )


Description

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 up to 15 arguments to that script. For more information about scripts, see Advanced Use: Scripts.

This function Will return the executed script's return value.


Example:

GML Code Example

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.




No Examples Submitted

Does this page need better examples? Be the first to Submit

These are page edits suggested by the community. Cast your vote to help improve the manual.

Suggested by /u/PixelatedPope on December 04, 2016

If the script you are executing should return a value, script_execute() WILL return the appropriate value, despite the "N/A" return value above.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here