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, or name, of the Variable you wish to access.

GVar myVariable1 = AC.GlobalVariables.GetVariable (int _id);
GVar myVariable2 = AC.GlobalVariables.GetVariable (string name);
GVar myVariable3 = AC.LocalVariables.GetVariable (int _id);
GVar myVariable4 = AC.LocalVariables.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 ++;