The index is used to call up variables in the list. You can specify this inside the variable editor by checking the Array box.Įach of these values has an index, or number in the array, with the first index being 0. You can set a variable using the 'Set Variable' trigger.Īn array is a variable that can store multiple values. The value of a variable can always be changed. Later you can set lesser variables as they are needed, or when an event happens. You can set important variables at the start of your map. The value of a variable can be set any time during the game. You can later change this during your game using trigger codes and custom scripts.Īfter creating a variable, you can always go back to the variable editor, and change the properties of the variable. Later, we will discuss the different types of variables and how they are used.īy default, the value of a new variable is 0, or none. When creating a variable, you will need to determine what kind of data type to use.įor example, an integer variable can only store a number, and a unit variable can only reference a single exsiting unit. There are many different data types used in Warcraft III. The type of a variable determines what kind of data it can store. This can also cause confusion during map making. Don't name your integer variable int, for example, or your string variable string. Avoid naming your variables the same as keywords or functions.Don't give names that are too similar to your variables.Using underscores is fine, though it's not recommended to begin a variable name with an underline. You may use underscores in a variable name, but not spaces.They can contain numbers, but you begin it with a letter. You should not begin a variable name with a number.Short, descriptive variable names are best. But index is better than i, count is better than c, and name is better than n. Single-letter variables are just hunky-dory. Use variable names that mean something.You can almost call variables whatever you like, so as long as you remember what they are. It is only a reference for you while you create your map. Here you can add any type of variable you will need for your map.Īll variables have a type, a name, and a value. Inside the Trigger Editor, you can click on Edit, Variables and load the variable editor. If your using custom scripts, you may also create certain types of variables within a trigger. In World Editor, variables are typically created inside the Variable Editor. You could also store the player that has killed the most units during the game using a player variable.
Storing information in a variable allows you to use it later.įor example, you could store the number of units a player has killed in an integer variable. Variables allow you to keep track of a certain unit, a winning player, a type of unit or even text strings. You can store almost any kind of data inside a variable. Variables play an important role in scripting because they enable programmers to write flexible programs. Variables are locations in memory that can hold values.