Variable Types
Each variable has a type, which indicates what type of data is beeing stored inside it.
There are two categories of variable types: primitive and complex. Primitive are simple data types, such as numbers, that contain small amount of data (1-4 B). Complex types take up much more space (for example point: it has 3 coordinates and facing angle, which are 4 numbers).
Primitive
Primitive variables are created and deleted as you use them dynamically (e.g. when a function/trigger with local variables is executed, all variables are created and given initial values), and their value is stored directly in their memory space. List of primitive variable types:
- int—32-bit signed integer. Range: −2,147,483,648 to +2,147,483,647.
- fixed—32-bit signed fixed-point rational number. Range: −524,288 to +524,287.999755859375. Precision: 1/4096.
- byte—8-bit unsigned integer. Range: 0 to 255.
- color—four bytes: red, green, blue, alpha.
Complex
Complex variables also require 4B of space, but this space is filled only with a pointer (a reference) to another space in memory, which contains the actual data. This means that every time you set a new value for this variable, a new memory is taken up and the pointer is pointed there. The old data space is then deleted automatically. This however creates unnecessary load for CPU, which can be avoided by intelligent design. (e.g. if you are updating a dialog for a player, do not call (Player group containing (Player X)) in each line, but just once at the beginning and save it in a variable. For each use a new player group is created in memory, and a milisecond later deleted.)
Another problem with complex types is the way operator == (comparsion) works. If you, for example, compare two timers, == will return true if both values are link to the same timer, not if the timers have same time left. There are few exceptions (abilcmd, point, string, unitfilter, unitref).
List of complex variable types (first are script names, second trigger names):
- abilcmd (Ability command)
- bank (Bank)
- camerainfo (Camera)
- marker
- order (Order)
- playergroup (Player Group)
- point (Point)
- region (Region)
- soundlink (Sound link)
- string (String)
- text (Text)
- timer (Timer)
- transmissionsource (Transmission source)
- unitfilter (Unit filter)
- unitgroup (Unit group)
- unitref
- waveinfo
- wavetarget
Fake
Some variable types are present only in trigger editor (in GUI), in script they are represented by a variable of other, usually primitive, type. List of trigger-only variable types:
- -Preset - individually set for each preset, but mostly int
- -Game link - always string
- -File - always string
- Actor Message - string
- Animation Name - string
- Attribute ID(both) - string
- Attribute value - string
- Cinematic - int
- Conversation - int
- Conversation reply - int
- Conversation state - string
- Dialog - int
- Dialog item - int
- Difficulty - int
- Leaderboad - int
- Mercenary - int
- Mission archive - int
- Model Camera - string
- Objective - int
- Ping - int
- Planet - int
- Player Color - int
- Purchase item - int
- Research (all three) - int
- Unit type - string
- Water - string