From SC2Mapster Wiki
Jump to: navigation, search

Data Types

About Types

Types are used by Variables, Functions, Presets and User Types for the game engine to store and reference specific kinds of data. In other words, integer variables can only store integers, and unit variables can only store units. The Parameters of Definitions require specific types to be defined to operate and Functions will only return values for specific parameter types. Some Conversion functions for the conversion of data between types do exist but the conversion of some types is less straight forward eg. the Point type.

Complex Types and Automatic Deletion

A number of types represent "complex" objects (i.e. objects larger than 4 bytes). These objects are larger than the maximum variable size (4 bytes) so have to be stored externally with a reference used to locate them. StarCraft II automatically keeps track of these objects and deletes them from memory when they are no longer referenced by the Galaxy virtual machine. Other types require that they be explicitly destroyed with the appropriate native function when no longer needed.

Types Affected by Automatic Deletion:

Complex Types and Equality

Comparing two "complex" objects with the == or != operators will only compare the object reference, not the contained object data in most cases. However, a few types will compare the contained data instead.

These types are:


//      Point(1, 2) == Point(1, 2)                              // True
//      "test string" == "test string"                          // True (note: this is case sensitive)
//      AbilityCommand("move", 0) == AbilityCommand("move", 0)  // True
//      Order(abilCmd) == Order(abilCmd)                        // False (two different order instances)
//      RegionEmpty() == RegionEmpty()                          // False (two different region instances)

Complex Types and + or - Operators

Other than numerical types (byte, int, fixed) the operators that support + and/or - operators are:

  • Point (+ or - Adds or Subtracts the X and Y values of the Points)
  • String (+ Concatenates the two Strings)
  • Text (+ Concatenates the two Texts)

Primitive Types

Game Types