variable_global_set


Description

With this function you can set the value of a given global variable. You supply the name of the global variable to set the value of as a string (see example code below), and then the value to set (can be any valid data type). If the global variable does not exist already in the game it will be created and then assigned the value.

NOTE: This function is primarily for use with Compatibility Scripts for imported projects and the converted code for Drag and Drop actions.


Syntax:

variable_global_set(name, val);


Arguments:

Argument Description
name The name of the global variable to set (as a string)
val The value to set the global variable to

Returns:

N/A


Example:

if !variable_global_exists("enemy_num")
   {
   variable_global_set("enemy_num", 0);
   }

The above code will check to see if a global variable exists and if it does not then it is created and set to 0.