Manipulating variables through script

Adventure Creator supports Global and Local Variables in the form of strings, ints, bools and floats. Variables are referenced by their ID number. This ID number is a number unique to a Variable, and is displayed to the left of a Variable's name in the Variables Manager. The ID number of the Tried lifting canvas Variable, for example, is 1:

During gameplay, Global and Local Variables are stored in the GlobalVariables and LocalVariables scripts respectively. Both contain static functions to aid in the reading and writing of the Variables they contain, if you provide an ID number of the Variable you wish to access.

GVar myVariable = AC.GlobalVariable.GetVariable (int _id);
GVar myVariable = AC.GlobalVariables.GetVariable (string name);

Component variables can also be gotten with a reference to the Variables component class:

Variables variables;
GVar myVariable = variables.GetVariable (int _id);

With a reference stored to the variable, we can then read or set its value based on its type:

myVariable.BooleanValue = true;
myVariable.FloatValue = 2.0f;
myVariable.IntegerValue ++;