Difference between revisions of "Variables"

From HIVE
Jump to navigation Jump to search
m (1 revision: StarEdit.net Wiki)
m
 
(5 intermediate revisions by 4 users not shown)
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.
  
The Variables themselves contain 4 important notions: Local variables, Global variables, Arrays and Constants.
+
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.
  
==Local==
+
==Variables Basics==
A '''Local variable''' is a variable that you will only be able to use within the trigger that contains 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.
  
==Global==
+
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.
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==
+
===Local Variables===
'''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.
+
A '''Local Variable''' is a variable that you will only be able to use within the one trigger that contains it.
  
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.
+
===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.
  
===The Trick===
+
===Arrays===
To prevent errors, it is always recommended to add 1 more array size than what you really need. Why? Because the '''Array #1 is [0]'''... this is really misleading. For example, if you have 4 Players and want to use arrays to differentiate a variable from these 4 players, you'll probably want to make it '''Var[1]''', '''Var[2]''', '''Var[3]''' and '''Var[4]'''. However, if you have set the Array Size of the variable "Var" to 4, the last array will be '''Var[3]''' (the first one would be '''Var[0]'''), and thus trying to set an information into '''Var[4]''' will cause problems. But if you set the Array Size to 5, you'll be able to just not use the first array ('''Var[0]''') and thus store information into the 4 others being '''Var[1]''', '''Var[2]''', '''Var[3]''' and '''Var[4]'''.
+
'''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.
  
It is also very useful for when it comes to "Picked integers". Indeed, if you're using a "Pick Each Integer" action to make some actions run, for example, for 10 players, you'll want to make the editor pick the integers between 1 and 10, inclusively. But if you try to use "Picked integer" for a Player number '''and''' a variable array (which is wise!), you'll have to have the variable have an array size of 11, because you cannot do Var[Picked Integer - 1].
+
===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.
  
==Constants==
+
==Variable Types==
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.
+
*[[Variables/Ability Command|Ability Command]]
 
+
*[[Variables/Actor|Actor]]
==Most used types==
+
*[[Variables/Actor Message|Actor Message]]
Among the pretty long list of [[Variable_Types_(List)|Variable Types]], there of course are some types you'll use more often than others. Here's an arbitrary list:
+
*[[Variables/Actor Scope|Actor Scope]]
*[[Boolean]]
+
*[[Variables/AI Filter|AI Filter]]
*[[Dialog]]
+
*[[Variables/Animation Name|Animation Name]]
*[[Dialog Item]]
+
*[[Variables/Attribute ID (Game)|Attribute ID (Game)]]
*Integer
+
*[[Variables/Attribute ID (Player)|Attribute ID (Player)]]
*[[Player Group]]
+
*[[Variables/Attribute Value|Attribute Value]]
*[[Unit Group]]
+
*[[Variables/Bank|Bank]]
 
+
*[[Variables/Boolean|Boolean]]
==See Also==
+
*[[Variables/Byte|Byte]]
*[[FAQs]]
+
*[[Variables/Camera Object|Camera Object]]
*[[Trigger]]
+
*[[Variables/Chat Bubble|Chat Bubble]]
 +
*[[Variables/Cinematic|Cinematic]]
 +
*[[Variables/Color|Color]]
 +
*[[Variables/Conversation|Conversation]]
 +
*[[Variables/Conversation Reply|Conversation Reply]]
 +
*[[Variables/Conversation State Index|Conversation State Index]]
 +
*[[Variables/Dialog|Dialog]]
 +
*[[Variables/Dialog Item|Dialog Item]]
 +
*[[Variables/Difficulty Level|Difficulty Level]]
 +
*[[Variables/Doodad|Doodad]]
 +
*[[Variables/Integer|Integer]]
 +
*[[Variables/Leaderboard|Leaderboard]]
 +
*[[Variables/Marker|Marker]]
 +
*[[Variables/Mercenary|Mercenary]]
 +
*[[Variables/Mission Archive|Mission Archive]]
 +
*[[Variables/Model Camera|Model Camera]]
 +
*[[Variables/Objective|Objective]]
 +
*[[Variables/Order|Order]]
 +
*[[Variables/Ping|Ping]]
 +
*[[Variables/Planet|Planet]]
 +
*[[Variables/Player Color|Player Color]]
 +
*[[Variables/Player Group|Player Group]]
 +
*[[Variables/Point|Point]]
 +
*[[Variables/Portrait|Portrait]]
 +
*[[Variables/Purchase Category|Purchase Category]]
 +
*[[Variables/Purchase Group|Purchase Group]]
 +
*[[Variables/Purchase Item|Purchase Item]]
 +
*[[Variables/Real|Real]]
 +
*[[Variables/Region|Region]]
 +
*[[Variables/Research Category|Research Category]]
 +
*[[Variables/Research Item|Research Item]]
 +
*[[Variables/Research Tier|Research Tier]]
 +
*[[Variables/Revealer|Revealer]]
 +
*[[Variables/Sound|Sound]]
 +
*[[Variables/Sound Link|Sound Link]]
 +
*[[Variables/String|String]]
 +
*[[Variables/Target Filter|Target Filter]]
 +
*[[Variables/Text|Text]]
 +
*[[Variables/Text Tag|Text Tag]]
 +
*[[Variables/Time Of Day|Time of Day]]
 +
*[[Variables/Timer|Timer]]
 +
*[[Variables/Timer Windows|Timer Windows]]
 +
*[[Variables/Transmission|Transmission]]
 +
*[[Variables/Transmission Source|Transmission Source]]
 +
*[[Variables/Trigger|Trigger]]
 +
*[[Variables/Unit|Unit]]
 +
*[[Variables/Unit Filter|Unit Filter]]
 +
*[[Variables/Unit Group|Unit Group]]
 +
*[[Variables/Unit Type|Unit Type]]
 +
*[[Variables/Water|Water]]
 +
*[[Variables/Wave|Wave]]
 +
*[[Variables/Wave Info|Wave Info]]
 +
*[[Variables/Wave Target|Wave Target]]
  
 
[[Category:StarCraft II]]
 
[[Category:StarCraft II]]
 +
[[Category:Triggers]]
 
[[Category:Reference]]
 
[[Category:Reference]]
[[Category:Triggers]]
 

Latest revision as of 10:21, 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