


Local variables only exist inside the function they were declared in.įor example, if you had a trigger that fired every time a unit was killed, and you were using a standard, global variable, the triggeres could possibly by overwriting that variable as new ones fired. Local variables are different from global variables. If it was true, I could collect the pears for the king. The statement will either be true or false.

Game - Display to (All players) the text: Fruitsīoolean logic is used to find out the overall answer to a number of conditional statements.Ī Boolean value can be either true or false - nothing else.Īn example statement would be 'I am ten feet tall or the tree has fallen'. I could also use Fruits in a loop, and display the types of fruits to players in the game.įor each (Integer A) from 0 to 3, do (Actions) Game - Display to (All players) the text: "The King wants you to collect an " + Fruits) Later in the game, If I wanted to tell a player to collect the pears, I could use Fruits to give them instructions. Inside my map initialization, I could set the different values of Fruits to what I will need later in my map. It is a way to access the indivudal values stored inside the array.įor example, I could have a variable called Fruits, which is an array of string variables. 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.
