Difference between revisions of "Variables"

From HIVE
Jump to navigation Jump to search
Line 1: Line 1:
'''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 [[Variable_Types_(List)|click here]].
+
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 [[Variable_Types_(List)|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 [[Dialog|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.
  
The Variables themselves contain 4 important notions: Local variables, Global variables, Arrays and Constants.
 
  
 
==Local==
 
==Local==
Line 16: Line 23:
 
==Constants==
 
==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.
 
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.
 
==Most used types==
 
Among the pretty long list of [[Variable Types]], there of course are some types you'll use more often than others. Here's an arbitrary list:
 
*[[Boolean]]
 
*[[Dialog]]
 
*[[Dialog Item]]
 
*Integer
 
*[[Player Group]]
 
*[[Unit Group]]
 
  
 
==See Also==
 
==See Also==
 
*[[FAQs]]
 
*[[FAQs]]
*[[Trigger]]
+
*[[Triggers]]
  
 
[[Category:StarCraft II]]
 
[[Category:StarCraft II]]
 
[[Category:Reference]]
 
[[Category:Reference]]
 
[[Category:Triggers]]
 
[[Category:Triggers]]

Revision as of 02:25, 25 December 2012

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