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 scripts 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.

AC.GlobalVariable.GetVariable (int _id);

Returns the entire variable class.

AC.GlobalVariables.GetIntegerValue (int _id);

Returns the value of an Integer

AC.GlobalVariables.GetBooleanValue (int _id);

Returns the value of a Boolean

AC.GlobalVariables.GetStringValue (int _id);

Returns the value of a String

AC.GlobalVariables.GetFloatValue (int _id);

Returns the value of a Float

AC.GlobalVariables.SetIntegerValue (int _id, int _value);

Sets the value of an Integer

AC.GlobalVariables.SetBooleanValue (int _id, bool _value);

Sets the value of a Boolean

AC.GlobalVariables.SetStringValue (int _id, string _value);

Sets the value of a String

AC.GlobalVariables.SetFloatValue (int _id, float _value);

Sets the value of a Float

Adventure Creator allows you to link Variables to those in the popular PlayMaker asset, as well. This is done internally by downloading and uploading values from one asset to the other. The GlobalVariables script contains the following associated static functions:

AC.GlobalVariables.DownloadAll ();

Transfers the values of all PlayMaker Variables to their linked Adventure Creator Variables.

AC.GlobalVariables.UploadAll ();

Transfers the values of all Adventure Creator Variables to their linked PlayMaker Variables.

Individual Variable values can be transferred by accessing their GVar class. For example, to download the value of Global Variable 2:

AC.GlobalVariables.GetVariable (2).Download ();

Adventure Creator and this website are copyright Chris Burton, ICEBOX Studios

Go to top
Do NOT follow this link or you will be banned from the site!