Headcannon Game Engine Script Commands - Math Operations (Flags)
These Commands manipulate an entry from an "Array" of variables.
An "Array" is simply a listing of variables that can be accessed
according to ID (their position in the list). Object Variables,
Player Variables, and Reg]sters are technically already Arrays, however, most Script Commands that
access them require an explicit ID value to be given, making it difficult to dynamically maintain lists.
These Commands allow truer use of the
array setup by allowing a list ID to be generated by whatever means desired and
retrieved from a variable, rather than requiring the script author to manually calculate and
enter a fixed ID. They allow the retrieval of a value from an arbitrary variable
(any variable whose ID is not known during script writing time, and which may change during
the course of gameplay) so that it can be stored in a variable with a known ID and read, or
manipulated by normal math or conditional Commands and then stored back into its original
array position, or any other position that may be desired.
They need not be used only for 2D
arrays. By manually keeping track of and calculating the sizes of and starting points of
array dimensions, it is possible to manage multi-dimensional arrays if they become necessary.
Index:
Retrieve an Array entry:
(D) (E) | _Reg=Reg[Reg] |
(D) (E) | _Reg=Reg[Chr] |
(D) (E) | _Reg=Reg[Obj] |
(D) (E) | _Reg=Chr[Reg] |
(D) (E) | _Reg=Chr[Chr] |
(D) (E) | _Reg=Chr[Obj] |
(D) (E) | _Reg=Obj[Reg] |
(D) (E) | _Reg=Obj[Chr] |
(D) (E) | _Reg=Obj[Obj] |
(D) (E) | _Chr=Reg[Reg] |
(D) (E) | _Chr=Reg[Chr] |
(D) (E) | _Chr=Reg[Obj] |
(D) (E) | _Chr=Chr[Reg] |
(D) (E) | _Chr=Chr[Chr] |
(D) (E) | _Chr=Chr[Obj] |
(D) (E) | _Chr=Obj[Reg] |
(D) (E) | _Chr=Obj[Chr] |
(D) (E) | _Chr=Obj[Obj] |
(D) (E) | _Obj=Reg[Reg] |
(D) (E) | _Obj=Reg[Chr] |
(D) (E) | _Obj=Reg[Obj] |
(D) (E) | _Obj=Chr[Reg] |
(D) (E) | _Obj=Chr[Chr] |
(D) (E) | _Obj=Chr[Obj] |
(D) (E) | _Obj=Obj[Reg] |
(D) (E) | _Obj=Obj[Chr] |
(D) (E) | _Obj=Obj[Obj] |
Set an Array entry:
(D) (E) | _Reg[Reg]=Reg |
(D) (E) | _Reg[Reg]=Chr |
(D) (E) | _Reg[Reg]=Obj |
(D) (E) | _Reg[Reg]=Const |
(D) (E) | _Reg[Chr]=Reg |
(D) (E) | _Reg[Chr]=Chr |
(D) (E) | _Reg[Chr]=Obj |
(D) (E) | _Reg[Chr]=Const |
(D) (E) | _Reg[Obj]=Reg |
(D) (E) | _Reg[Obj]=Chr |
(D) (E) | _Reg[Obj]=Obj |
(D) (E) | _Reg[Obj]=Const |
(D) (E) | _Chr[Reg]=Reg |
(D) (E) | _Chr[Reg]=Chr |
(D) (E) | _Chr[Reg]=Obj |
(D) (E) | _Chr[Reg]=Const |
(D) (E) | _Chr[Chr]=Reg |
(D) (E) | _Chr[Chr]=Chr |
(D) (E) | _Chr[Chr]=Obj |
(D) (E) | _Chr[Chr]=Const |
(D) (E) | _Chr[Obj]=Reg |
(D) (E) | _Chr[Obj]=Chr |
(D) (E) | _Chr[Obj]=Obj |
(D) (E) | _Chr[Obj]=Const |
(D) (E) | _Obj[Reg]=Reg |
(D) (E) | _Obj[Reg]=Chr |
(D) (E) | _Obj[Reg]=Obj |
(D) (E) | _Obj[Reg]=Const |
(D) (E) | _Obj[Chr]=Reg |
(D) (E) | _Obj[Chr]=Chr |
(D) (E) | _Obj[Chr]=Obj |
(D) (E) | _Obj[Chr]=Const |
(D) (E) | _Obj[Obj]=Reg |
(D) (E) | _Obj[Obj]=Chr |
(D) (E) | _Obj[Obj]=Obj |
(D) (E) | _Obj[Obj]=Const |
Descriptions:
Retrieve an Array entry:
_Reg=Reg[Reg]
_Reg=Reg[Chr]
_Reg=Reg[Obj]
_Reg=Chr[Reg]
_Reg=Chr[Chr]
_Reg=Chr[Obj]
_Reg=Obj[Reg]
_Reg=Obj[Chr]
_Reg=Obj[Obj]
_Chr=Reg[Reg]
_Chr=Reg[Chr]
_Chr=Reg[Obj]
_Chr=Chr[Reg]
_Chr=Chr[Chr]
_Chr=Chr[Obj]
_Chr=Obj[Reg]
_Chr=Obj[Chr]
_Chr=Obj[Obj]
_Obj=Reg[Reg]
_Obj=Reg[Chr]
_Obj=Reg[Obj]
_Obj=Chr[Reg]
_Obj=Chr[Chr]
_Obj=Chr[Obj]
_Obj=Obj[Reg]
_Obj=Obj[Chr]
_Obj=Obj[Obj]
(ALL) (Example)
These Commands use a script-generated ID to retrieve an entry from an "Array" of Object Variables, Player Variables, or
Reg]sters, and store it in another variable with a known ID.
In the case of a Player Array and a Player Index, the Array is considered to reside in the Player "Fetched"
to "Reference 1", and the Index is read from the Player "Fetched" to "Reference 0".
In the case of an Object Array and an Object Index, the Array is considered to reside in the Object "Fetched"
to "Reference 1", and the Index is read from the Object "Fetched" to "Reference 0".
In the case that only one Player is used for input, and/or only one Object is used for input, the Player
"Fetched" to "Reference 0" is used, and the Object "Fetched" to "Reference 0 is used.
Parameters:
- Var ID for Start
In the case of "Reg]sters", This is the ID of the "Reg]ster" at which the "Array" starts (this Array's "Index 0"). The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable at which the "Array" starts (this Array's "Index 0"). The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable at which the "Array" starts (this Array's "Index 0"). The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Var ID for Index
In the case of "Reg]sters", This is the ID of the "Reg]ster" that contains the desired Array Index value. The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable that contains the desired Array Index value. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable that contains the desired Array Index value. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Dest Var ID
In the case of "Reg]sters", This is the ID of the "Reg]ster" that should receive the value retrieved from the given Array entry. The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" that should receive the value retrieved from the given Array entry. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" that should receive the value retrieved from the given Array entry. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
Set an Array entry:
_Reg[Reg]=Reg
_Reg[Reg]=Chr
_Reg[Reg]=Obj
_Reg[Reg]=Const
_Reg[Chr]=Reg
_Reg[Chr]=Chr
_Reg[Chr]=Obj
_Reg[Chr]=Const
_Reg[Obj]=Reg
_Reg[Obj]=Chr
_Reg[Obj]=Obj
_Reg[Obj]=Const
_Chr[Reg]=Reg
_Chr[Reg]=Chr
_Chr[Reg]=Obj
_Chr[Reg]=Const
_Chr[Chr]=Reg
_Chr[Chr]=Chr
_Chr[Chr]=Obj
_Chr[Chr]=Const
_Chr[Obj]=Reg
_Chr[Obj]=Chr
_Chr[Obj]=Obj
_Chr[Obj]=Const
_Obj[Reg]=Reg
_Obj[Reg]=Chr
_Obj[Reg]=Obj
_Obj[Reg]=Const
_Obj[Chr]=Reg
_Obj[Chr]=Chr
_Obj[Chr]=Obj
_Obj[Chr]=Const
_Obj[Obj]=Reg
_Obj[Obj]=Chr
_Obj[Obj]=Obj
_Obj[Obj]=Const
(ALL) (Example)
These Commands use a script-generated ID to set the value of an entry within an "Array" of Object Variables, Player Variables, or
Reg]sters to the value of another variable with a known ID.
The Array is always considered to reside in the Player/Object "Fetched" to "Reference 2"
The Index is always read from the Player/Object "Fetched" to "Reference 1".
The Data is always read from the Player/Object "Fetched" to "Reference 0".
Parameters:
- Src Var ID
In the case of "Reg]sters", This is the ID of the "Reg]ster" that contains the value that should be placed into the given Array entry. The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable that contains the value that should be placed into the given Array entry. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable that contains the value that should be placed into the given Array entry. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Var ID for Start
In the case of "Reg]sters", This is the ID of the "Reg]ster" at which the "Array" starts (this Array's "Index 0"). The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" at which the "Array" starts (this Array's "Index 0"). The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" at which the "Array" starts (this Array's "Index 0"). The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Var ID for Index
In the case of "Reg]sters", This is the ID of the "Reg]ster" that contains the desired Array Index value. The "U" tag may be used
to specify a user-defined Reg]ster. Otherwise, the ID will refer to a Game Reg]ster
In the case of Player Variables, This is the ID of the Player Variable that contains the desired Array Index value. The capital "A"
tag may be used to specify an "Active" variable, the lower-case "a" to specify a user-
defined "Active" variable, and the lower-case "c" to specify a user-defined Constant.
Otherwise, the ID will refer to one of the Player's required Constants
In the case of Object Variables, This is the ID of the Object Variable that contains the desired Array Index value. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
Examples:
#_Reg=Chr[Obj] ;From the Array starting at User-created "Active Variable" 36 of the Player "Fetched" to "Reference 0", retrieve the value of the entry whose ID is stored in "Extra Variable" 8 of the "Object" "Fetched" to "Reference 0", and place it in "User Reg]ster" 26
: a36 ;(Array Start) User-created "Active Variable" 36 of the Player "Fetched" to "Reference 0"
: E8 ;(Index) "Extra Variable" 8 of the "Object" "Fetched" to "Reference 0"
: U26 ;(Dest) "User Reg]ster" 26
; ----------
#_Chr=Chr[Chr] ;From the Array starting at User-created "Active Variable" 24 of the Player "Fetched" to "Reference 1", retrieve the value of the entry whose ID is stored in User-created "Active Variable" 1 of the Player "Fetched" to "Reference 0", and place it in User-created "Active Variable" 0 of the Player "Fetched" to "Reference 2"
: a24 ;(Array Start) User-created "Active Variable" 24 of the Player "Fetched" to "Reference 1"
: a1 ;(Index) User-created "Active Variable" 1 of the Player "Fetched" to "Reference 0"
: a0 ;(Dest) User-created "Active Variable" 0 of the Player "Fetched" to "Reference 2"
; ----------
#_Obj=Reg[Reg] ;From the Array starting at "User Reg]ster" 5, retrieve the value of the entry whose ID is stored in "User Reg]ster" 4, and place it in "Extra Variable" 10 of the "Object" "Fetched" to "Reference 2"
: U5 ;(Array Start) "User Reg]ster" 5
: U4 ;(Index) "User Reg]ster" 4
: E10 ;(Dest) "Extra Variable" 10 of the "Object" "Fetched" to "Reference 2"
Set an Array entry:
#_Obj[Chr]=Reg ;In the Array starting at "Extra Variable" 8 of the "Object" "Fetched" to "Reference 2", at the entry whose ID is stored in User-created "Active Variable" 36 of the Player "Fetched" to "Reference 1", store the value of "User Reg]ster" 26
: U26 ;(Src) "User Reg]ster" 26
: E8 ;(Array Start) "Extra Variable" 8 of the "Object" "Fetched" to "Reference 2"
: a36 ;(Index) User-created "Active Variable" 36 of the Player "Fetched" to "Reference 1"
; ----------
#_Chr[Chr]=Chr ;In the Array starting at User-created "Active Variable" 24 of the Player "Fetched" to "Reference 2", at the entry whose ID is stored in User-created "Active Variable" 1 of the Player "Fetched" to "Reference 1", store the value of User-created "Active Variable" 0 of the Player "Fetched" to "Reference 0"
: a0 ;(Src) User-created "Active Variable" 0 of the Player "Fetched" to "Reference 0"
: a24 ;(Array Start) User-created "Active Variable" 24 of the Player "Fetched" to "Reference 2"
: a1 ;(Index) User-created "Active Variable" 1 of the Player "Fetched" to "Reference 1"
; ----------
#_Reg[Reg]=Obj ;In the Array starting at "User Reg]ster" 5, at the entry whose ID is stored in "User Reg]ster" 4, store the value of "Extra Variable" 10 of the "Object" "Fetched" to "Reference 0"
: E10 ;(Src) "Extra Variable" 10 of the "Object" "Fetched" to "Reference 0"
: U5 ;(Array Start) "User Reg]ster" 5
: U4 ;(Index) "User Reg]ster" 4