Difference between revisions of "Variables"

From HIVE
Jump to: navigation, 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 that you will be able to call later on. This information can be pretty much anything from units to players, passing by regions, orders, sounds, and much '''much''' more.
  
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.
 
 
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.
 
  
 +
==Variables Basics==
 
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.
 
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.
 
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 Variables===
 +
A '''Local Variable''' is a variable that you will only be able to use within the one trigger that contains it.
  
==Local==
+
===Global Variable===
A '''Local variable''' is a variable that you will only be able to use within the trigger that contains it.
+
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.
 
 
==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.
+
===Arrays===
 +
'''Arrays''' are extremely useful and time-saving when you learn to use them properly. They are used to store different information into the same variable. Let's say you have a Variable that you want to change based on what different players do, but you don't want the changes one player makes to affect the variable for another player. By checking the box next to "Array" and setting the size to the amount of players in your game, you can then link to whateverVariable[1] and have that specifically be for Player 1's triggers, then set up whateverVariable[2] for Player 2, and so on. Of course this also isn't limited to something as simple as that. Arrays are most helpful when you just want to keep your variables organized and minimal rather than having to create a ton of variables that serve a similar purpose.
  
==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.
  
==See Also==
+
==Variable Types==
*[[FAQs]]
+
*[[Variables/Ability Command]]
*[[Triggers]]
+
*[[Variables/Actor]]
 +
*[[Variables/Actor Message]]
 +
*[[Variables/Actor Scope]]
 +
*[[Variables/AI Filter]]
 +
*[[Variables/Animation Name]]
 +
*[[Variables/Attribute ID (Game)]]
 +
*[[Variables/Attribute ID (Player)]]
 +
*[[Variables/Attribute Value]]
 +
*[[Variables/Bank]]
 +
*[[Variables/Boolean]]
 +
*[[Variables/Byte]]
 +
*[[Variables/Camera Object]]
 +
*[[Variables/Chat bubble]]
 +
*[[Variables/Cinematic]]
 +
*[[Variables/Color]]
 +
*[[Variables/Conversation]]
 +
*[[Variables/Conversation Reply]]
 +
*[[Variables/Conversation State Index]]
 +
*[[Variables/Dialog]]
 +
*[[Variables/Dialog Item]]
 +
*[[Variables/Difficulty Level]]
 +
*[[Variables/Doodad]]
 +
*[[Variables/Integer]]
 +
*[[Variables/Leaderboard]]
 +
*[[Variables/Marker]]
 +
*[[Variables/Mercenary]]
 +
*[[Variables/Mission Archive]]
 +
*[[Variables/Model Camera]]
 +
*[[Variables/Objective]]
 +
*[[Variables/Order]]
 +
*[[Variables/Ping]]
 +
*[[Variables/Planet]]
 +
*[[Variables/Player Color]]
 +
*[[Variables/Player Group]]
 +
*[[Variables/Point]]
 +
*[[Variables/Portrait]]
 +
*[[Variables/Purchase Category]]
 +
*[[Variables/Purchase Group]]
 +
*[[Variables/Purchase Item]]
 +
*[[Variables/Real]]
 +
*[[Variables/Region]]
 +
*[[Variables/Research Category]]
 +
*[[Variables/Research Item]]
 +
*[[Variables/Research Tier]]
 +
*[[Variables/Revealer]]
 +
*[[Variables/Sound]]
 +
*[[Variables/Sound Link]]
 +
*[[Variables/String]]
 +
*[[Variables/Target Filter]]
 +
*[[Variables/Text]]
 +
*[[Variables/Text Tag]]
 +
*[[Variables/Time Of Day]]
 +
*[[Variables/Timer]]
 +
*[[Variables/Timer Windows]]
 +
*[[Variables/Transmission]]
 +
*[[Variables/Transmission Source]]
 +
*[[Variables/Trigger]]
 +
*[[Variables/Unit]]
 +
*[[Variables/Unit Filter]]
 +
*[[Variables/Unit Group]]
 +
*[[Variables/Unit Type]]
 +
*[[Variables/Water]]
 +
*[[Variables/Wave]]
 +
*[[Variables/Wave Info]]
 +
*[[Variables/Wave Target]]
  
 
[[Category:StarCraft II]]
 
[[Category:StarCraft II]]
 
[[Category:Reference]]
 
[[Category:Reference]]
 
[[Category:Triggers]]
 
[[Category:Triggers]]

Revision as of 10:12, 27 March 2013

Variables are used to store information that you will be able to call later on. This information can be pretty much anything from units to players, passing by regions, orders, sounds, and much much more.

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.

Variables Basics

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 Variables

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

Global Variable

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 information into the same variable. Let's say you have a Variable that you want to change based on what different players do, but you don't want the changes one player makes to affect the variable for another player. By checking the box next to "Array" and setting the size to the amount of players in your game, you can then link to whateverVariable[1] and have that specifically be for Player 1's triggers, then set up whateverVariable[2] for Player 2, and so on. Of course this also isn't limited to something as simple as that. Arrays are most helpful when you just want to keep your variables organized and minimal rather than having to create a ton of variables that serve a similar purpose.

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.

Variable Types