Variables

From HIVE
Revision as of 02:25, 25 December 2012 by MarkOfCain (talk | contribs)
Jump to navigation Jump to search

Variables are used to store information into something that you will be able to call later on. This information can be pretty much anything (not just numbers!), from units to players, passing by regions, orders, sounds, and much much more. For a complete list of the Variable Types, please click here.

When making a variable there are also many ways to create one, locally and globally. Both function the same way, but local variables can only be accessed by the trigger in which it was defined.

To create a variable, right click the left area in the Trigger Window, go to New, then New Variable (CTRL + B). Now you need a type, a name, and sometimes a value or configure it to be an array. Types go from Units, to Player Groups (Forces), integers (number with no decimal) and reals (number with decimal), and most objects dealing with leaderboards and dialogs. An integer is a great way to store information needed in triggers later on, and SC1 veterans who know Death Counters will understand them rather easily.

Writing to a variable is as simple as making a new action, and choosing the option that first comes up, which is 'Set Variable'. When setting a variable, the editor will automatically populate the list with reasonable things to put into it.

When reading a variable, conditions vary. Bringing a unit to a location can also be done by bringing a variable to a location, if the unit is inside the Unit variable. Even math can be done, in the math section of the conditions list, to variables containing numbers and can allow you to do more things in only one trigger.


Local

A Local variable is a variable that you will only be able to use within the trigger that contains it.

Global

A Global variable is used to transcend the boundaries of the triggers, thus allowing you to use it anywhere. They are created on the left-tree, where triggers and folders are listed.

Arrays

Arrays are extremely useful and time-saving when you learn to use them properly. They are used to store different informations into the same variable.

What is the difference between having 10 different variables and 1 variable with 10 arrays? Well, with the arrays, you can use an Integer to call data, which will save you a lot of time.

Constants

A Constant "type" variable is one that you will not be able to change. You set its initial value, and it'll always stay as it is.

See Also