script_exists


Syntax:

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 The Script Editor.


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.