variable_instance_exists(instance_id, name);
Argument | Description |
---|---|
instance_id | The unique ID value of the instance to check |
name | The name of the variable to check for (as a string) |
Returns: Boolean
With this function you can check whether an instance scope
variable exists or not. You supply the unique instance ID value
(which can be found from the room editor, or is returned when you
call the function instance_create) as well as the variable
name to check for as a string (see example code below). The
function will return true if a variable with the given
name exists for the instance and false otherwise.
if !variable_instance_exists(id, "shields")) shields = 0;
The above code will check to see if the variable called "shields" exists in the instance running the code and if it does not then it is created and initialised to 0.