script_exists

Returns whether a script with the given index exists.

Syntax:

GML Code Example

script_exists(scr);


Argument Description
scr The name of the script that you want to check.


Returns: Boolean


Description

This function will return true or false depending on whether the script with the given index exists. Note, that this is not a string, but rather the asset name which holds the unique index for each script (as it would appear in the IDE). For more information on scripts, see Advanced Use: Scripts.


Example:

GML Code Example

script[0] = -1;
 script[1] = scr_AI_Left;
 script[2] = scr_AI_Right;
 var script_num = choose(0, 1, 2);
 if script_exists(script[script_num])
    {
    script_execute(script[script_num]);
    }
 

The above example adds two scripts and a value into an array, then proceeds to get a random number and use that to choose a script to run, unless the real is chosen in which case nothing will happen.





No Examples Submitted

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

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

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