Variables

A variable is a space for storing data in a trigger. A variable stores data temporarily: when the map is closed in-game, the data is lost. Every variable has a name, identifier and data type. You can also mark a variables as being a constant which is a special variable which cannot have its value modifier.

Variable Scope
A variable scope indicates where the variable can be used. A variable can have two types of scope:
 * Local: These variables are used within one particular trigger only. The variable is accessible once the trigger starts, and is no longer used when the trigger ends. You can declare a local variable from within a trigger definition in the Trigger Editor.
 * Global: These variables start to exist immediately when you open up the map in-game and are accessible by all your triggers for the duration of the game. You can declare a global variable by right-clicking on the trigger list on the left in the Trigger Editor, go to New and click on New Variable.

Arrays
Arrays are a set of variables, all with the same name but can be accessed individually using an integer. When you set a variable as being an array, you need to set its size. For example, if you set a Region array, called reg, to size 5, you get five variables (technically six) each named reg[1], reg[2], reg[3], reg[4], reg[5]. The number within the square brackets can be any integer variable so that you can use a for loop to access all elements in the array quickly.

Initial Value
You can set the inital value of a variable which is the value assigned immediately when the variable is declared. Simply double-click on Initial Value while having a variable selected to set the initial value. You can set the initial value to anything from a function or even another variable.

The SetVariable Action
You can use the Set Variable action to set the value of the value. After adding the action, choose the variable you wish to set and then choose a value you want to set to the variable. Notice how the editor will only let you select values that are of the same type of the selected variable.