With this function you can check whether a global scope variable exists or not. You supply the global variable name to check for as a string (see example code below) and the function will return true if a global variable with the given name exists or false otherwise.
variable_global_exists(name);
Argument | Type | Description |
---|---|---|
name | String | The name of the global variable to check for (as a string) |
if (!variable_global_exists("enemy_num"))
{
global.enemy_num = instance_number(obj_Enemey_Parent);
}
The above code will check to see if the global variable called enemy_num exists and if it does not it is created and set a value.