Difference between revisions of "Variable Types"

From HIVE
Jump to navigation Jump to search
Line 4: Line 4:
  
 
==Variable types==
 
==Variable types==
There are two categories of variable types: primitive and complex. Primitive are simple data types, such as numbers, that contain small amount of data (4B, regardless of type). Complex types take up much more space (for example point: it has 3 coordinates and facing angle, which are 4 numbers).
+
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===
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 4B data space.
+
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.
 
===Complex===
 
===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 contining (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.)
 
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 contining (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.)

Revision as of 14:43, 19 May 2011

A variable is basically a space in memory, that game script (triggers) use for storing data.

Each variable has a type, which indicates what type of data is beeing stored inside it (e.g. a number, text or color), and can be defined as up to 4-dimensional array.

Variable types

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.

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 contining (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.)


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

Some variable types are present only in trigger editor, in script they are represented by a variable of other 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