gamevar <varname> <value> <flags>
var <varname> <value> <flags>
The gamevar's flags define a bitmap that determines how the variable is treated by the game. For instance, a gamevar with flags of 0 is known as a global variable. A global variable exists once in the code, and any time a global variable is set, the new value is seen by all actors and events. A gamevar with flag bit 1 set is a per-player variable, which exists once for each player in the game. A gamevar with flag bit 2 set is a per-actor variable, which exists as many times in the code as there are sprites in the map. This means that each sprite has its own copy of a per-actor variable stored in memory. Note that a gamevar can only be defined as either global, per-player, or per-actor, but not as a combination thereof.
Gamevars are stored as signed 32-bit integers and therefore have a value range of -2,147,483,648 (-231) to 2,147,483,647 (231-1). Going above and below this range causes the value to overflow and underflow respectively.
Note that it is possible to omit the <value> and <flags> parameters entirely to define a global variable with an initial value of 0, with no other flags set. Example:
It is also possible to chain flags separately at the end of the gamevar definition, instead of compiling them into a single value, as follows:
var TEMP2 10 1 4096 // This defines a per-player (1), read-only (4096) variable with initial value 10.
The following pages contain information on basic gamevar operations as well as conditional statements:
The following table shows all currently defined gamevar flags. The first 2 are the only ones needed under normal circumstances, but one can also assign higher flags to user-defined gamevars (given that you know what you are doing).
|3||GAMEVAR_USER_MASK||Bitmask controlling what flags can be set from con; only flags less than this can.|
|256||GAMEVAR_FLAG_DEFAULT||Allow override (not used).|
|256||GAMEVAR_DEFAULT||Allow override (not used, but always cleared for user-defined gamevars).|
|Yes||1024||GAMEVAR_NODEFAULT||Don't reset. Useful if you want a variable to be set once you start the game (otherwise it's reset each time you start a new game).|
|2048||GAMEVAR_SYSTEM||Cannot change mode flags...(only default value)|
|4096||GAMEVAR_READONLY||Values are read-only (no setvar allowed)|
|8192||GAMEVAR_INT32PTR||plValues is a pointer to an int32_t|
|16384||GAMEVAR_FLAG_SYNCCHECK||check event sync when translating|
|32768||GAMEVAR_INT16PTR||plValues is a pointer to a short|
|Yes||131072||GAMEVAR_NORESET||Variable values are not reset when restoring map state|
|262144||GAMEVAR_SPECIAL||Flag for structure member shortcut vars|
|Yes||524288||GAMEVAR_NOMULTI||Don't attach to multiplayer packets|
|1048576||GAMEVAR_Q16PTR||plValues is a pointer to a q16.16|
|Yes||2097152||GAMEVAR_SERIALIZE||Write into permasaves|
This category has the following 3 subcategories, out of 3 total.
Pages in category "Gamevar manipulation"
The following 82 pages are in this category, out of 82 total.