Headcannon Game Engine Script Commands - Math Operations (Flags)
Any variable can be used as a "Bitfield" instead of a full value. Each Bit in this "Bitfield"
is refered to as a "Flag".
Each variable used as a "Bitfield" contains 32 "Flags" that can
be turned "on" or "off" (the value of 1 or 0).
"Flags" are a nice way to save variable space
when there are several values that can be expressed simply as "On"/"Off", "True"/"False", etc
Flag IDs for each variable are always numbered 0 - 31.
Index:
Setting Flags:
(D) (E) | _SetFlag_Reg |
(D) (E) | _SetFlag_Chr |
(D) (E) | _SetFlag_Obj |
(D) (E) | _SetFlag_Reg_ByReg |
(D) (E) | _SetFlag_Chr_ByReg |
(D) (E) | _SetFlag_Obj_ByReg |
Unsetting Flags:
(D) (E) | _ClearFlag_Reg |
(D) (E) | _ClearFlag_Chr |
(D) (E) | _ClearFlag_Obj |
(D) (E) | _ClearFlag_Reg_ByReg |
(D) (E) | _ClearFlag_Chr_ByReg |
(D) (E) | _ClearFlag_Obj_ByReg |
Flipping Flags:
(D) (E) | _FlipFlag_Reg |
(D) (E) | _FlipFlag_Chr |
(D) (E) | _FlipFlag_Obj |
(D) (E) | _FlipFlag_Reg_ByReg |
(D) (E) | _FlipFlag_Chr_ByReg |
(D) (E) | _FlipFlag_Obj_ByReg |
Descriptions:
Setting Flags:
_SetFlag_Reg
_SetFlag_Chr
_SetFlag_Obj
_SetFlag_Reg_ByReg
_SetFlag_Chr_ByReg
_SetFlag_Obj_ByReg
(ALL) (Example)
These Commands are used to "Set" (turn on) a "Flag" within the given variable.
The "_ByReg" versions allow the use of a Register to dynamically specify Flag ID, as opposed to providing a fixed ID.
Parameters:
- Var ID
In the case of "Registers", "Var ID" is the ID of the "Register" that contains the desired Flag. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" that contains the desired Flag. 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, "Var ID" is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" that contains the desired Flag. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Flag ID
In the case of the standard versions, this is the ID number of the Flag to manipulate
In the case of the "_ByReg" versions, this is the ID number of a Register that contains the ID number of the Flag to manipulate. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Unsetting Flags:
_ClearFlag_Reg
_ClearFlag_Chr
_ClearFlag_Obj
_ClearFlag_Reg_ByReg
_ClearFlag_Chr_ByReg
_ClearFlag_Obj_ByReg
(ALL) (Example)
These Commands are used to "Clear" (turn off) a "Flag""Flag" within the given variable.
The "_ByReg" versions allow the use of a Register to dynamically specify Flag ID, as opposed to providing a fixed ID.
Parameters:
- Var ID
In the case of "Registers", "Var ID" is the ID of the "Register" that contains the desired Flag. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" that contains the desired Flag. 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, "Var ID" is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" that contains the desired Flag. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Flag ID
In the case of the standard versions, this is the ID number of the Flag to manipulate
In the case of the "_ByReg" versions, this is the ID number of a Register that contains the ID number of the Flag to manipulate. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Flipping Flags:
_FlipFlag_Reg
_FlipFlag_Chr
_FlipFlag_Obj
_FlipFlag_Reg_ByReg
_FlipFlag_Chr_ByReg
_FlipFlag_Obj_ByReg
(ALL) (Example)
These Commands are used to "Flip" a "Flag" within the given variable.
A "Set" (1) value will become "Unset" (0), and an "Unset" (0) value will become "Set" (1).
The "_ByReg" versions allow the use of a Register to dynamically specify Flag ID, as opposed to providing a fixed ID.
Parameters:
- Var ID
In the case of "Registers", "Var ID" is the ID of the "Register" that contains the desired Flag. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
In the case of Player Variables, "Var ID" is the ID of the Player Variable for the Player that is "Fetched" to "Reference 2" that contains the desired Flag. 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, "Var ID" is the ID of the Object Variable for the Object that is "Fetched" to "Reference 2" that contains the desired Flag. The "E" tag may
be used to specify an "Extra" variable. Otherwise, the ID will refer to one of the
Object's standard variables
- Flag ID
In the case of the standard versions, this is the ID number of the Flag to manipulate
In the case of the "_ByReg" versions, this is the ID number of a Register that contains the ID number of the Flag to manipulate. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Examples:
#_SetFlag_Reg ;Turn On Flag/Bit 6 in "User Register" 24
: U24 ;(Reg) "User Register" 24
: 6 ;(Flag) Flag/Bit 6
; ----------
#_SetFlag_Chr ;Turn On Flag/Bit 0 in User-created "Active Variable" 5 of the Player "Fetched" to "Reference 2"
: a5 ;(Chr2) User-created "Active Variable" 5 of the Player "Fetched" to "Reference 2"
: 0 ;(Flag) Flag/Bit 0
; ----------
#SetFlag_Obj_ByReg ;In "Extra Variable" 2 of the Object "Fetched" to "Reference 2", Turn On the Flag/Bit whose ID is stored in "User Register" 8
: E2 ;(Obj2) "Extra Variable" 2 of the Object "Fetched" to "Reference 2"
: U8 ;(Flag) Flag whose ID is stored in "User Register" 8
Unsetting Flags:
#_ClearFlag_Reg ;Turn Off Flag/Bit 17 in "User Register" 11
: U11 ;(Reg) "User Register" 11
: 17 ;(Flag) Flag/Bit 17
; ----------
#_ClearFlag_Chr_ByReg ;In User-created "Active Variable" 9 of the Player "Fetched" to "Reference 2", Turn Off the Flag/Bit whose ID is stored in "User Register" 3
: a9 ;(Chr2) User-created "Active Variable" 9 of the Player "Fetched" to "Reference 2"
: U3 ;(Flag) Flag whose ID is stored in "User Register" 3
; ----------
#_ClearFlag_Obj ;Turn Off Flag/Bit 30 in "Extra Variable" 1 of the Object "Fetched" to "Reference 2"
: E1 ;(Obj2) "Extra Variable" 1 of the Object "Fetched" to "Reference 2"
: 30 ;(Flag) Flag/Bit 30
Flipping Flags:
#_FlipFlag_Reg_ByReg ;In "User Register" 14, Reverse the Flag/Bit whose ID is stored in "User Register" 6
: U14 ;(Reg) "User Register" 14
: U6 ;(Flag) Flag whose ID is stored in "User Register" 6
; ----------
#_FlipFlag_Chr ;Reverse Flag/Bit 31 in User-created "Active Variable" 7 of the Player "Fetched" to "Reference 2"
: a7 ;(Chr2) User-created "Active Variable" 7 of the Player "Fetched" to "Reference 2"
: 31 ;(Flag) Flag/Bit 31
; ----------
#_FlipFlag_Obj ;Reverse Flag/Bit 24 in "Extra Variable" 8 of the Object "Fetched" to "Reference 2"
: E8 ;(Obj2) "Extra Variable" 8 of the Object "Fetched" to "Reference 2"
: 24 ;(Flag) Flag/Bit 24