Headcannon Game Engine Script Commands - If Conditionals (Flags)
"If Blocks" test for certain conditions, and cause the code within to be processed only if
that condition is true. They start with any available "If" Command to define the condition,
and must be ended with an "EndIf" command.
If the condition is true,
processing continues through the code within the "If Block", through the "EndIf", and beyond.
If the condition is not true, the code within the Block is skipped, and processing
resumes with the Command that immediately follows that Block's "EndIF".
Also available is the "Else" Command, which causes code to execute when the
condition is not true. An "IF"/"Else"/"EndIf" Block starts with the desired "IF" Command,
followed by code to execute if the condition is true, and then the "Else" Command, followed by the
code to execute if the condition is not true, and finally, the "EndIf" Command.
Index:
Flag Test IFs:
(D) (E) | _If(Reg_Flag) |
(D) (E) | _If(Not_Reg_Flag) |
(D) (E) | _If(Chr_Flag) |
(D) (E) | _If(Not_Chr_Flag) |
(D) (E) | _If(Obj_Flag) |
(D) (E) | _If(Not_Obj_Flag) |
(D) (E) | _If(Reg_Flag_ByReg) |
(D) (E) | _If(Not_Reg_Flag_ByReg) |
(D) (E) | _If(Chr_Flag_ByReg) |
(D) (E) | _If(Not_Chr_Flag_ByReg) |
(D) (E) | _If(Obj_Flag_ByReg) |
(D) (E) | _If(Not_Obj_Flag_ByReg) |
Descriptions:
Flag Test IFs:
_If(Reg_Flag)
_If(Not_Reg_Flag)
_If(Chr_Flag)
_If(Not_Chr_Flag)
_If(Obj_Flag)
_If(Not_Obj_Flag)
_If(Reg_Flag_ByReg)
_If(Not_Reg_Flag_ByReg)
_If(Chr_Flag_ByReg)
_If(Not_Chr_Flag_ByReg)
_If(Obj_Flag_ByReg)
_If(Not_Obj_Flag_ByReg)
(ALL) (Example)
These "If" condition commands test individual Bits (Flags) within a variable for "On" (1)
or "Off"/"Not On" (0)
All variables hold 32-bit values, so, each is capable of holding 32 "Flags", with IDs ranging from 0 to 31
Parameters:
- Var ID
This is the ID of the variable which contains the desired Flag
In the case of "Registers", "Var ID" is the ID of the "Register" to test. 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, the Player whose variable should be tested must be Fetched to Reference 0, and "Var ID" is the ID of the Player Variable to test. 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, the Object whose variable should be tested must be Fetched to Reference 0, and "Var ID" is the ID of the Object Variable to test. 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
For standard "IF Flag" tests, this is the ID number of the Flag to test
For "ByReg" tests, this is the ID number of the Register whose value should be used as the Flag ID. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Examples:
Flag Test IFs:
This section lists examples of complete sets of "If"/"Else"/"Endif" Commands, because they have no individual use
_If(Reg_Flag)
_If(Not_Reg_Flag)
_If(Chr_Flag)
_If(Not_Chr_Flag)
_If(Obj_Flag)
_If(Not_Obj_Flag)
_If(Reg_Flag_ByReg)
_If(Not_Reg_Flag_ByReg)
_If(Chr_Flag_ByReg)
_If(Not_Chr_Flag_ByReg)
_If(Obj_Flag_ByReg)
_If(Not_Obj_Flag_ByReg)
(Description)
#_If(Reg_Flag)
: U12 ;(Reg) User Register 12
: 0 ;(Flag) Flag 0
;***
;Code here is processed only if Flag (Bit) 0 of User Register 12 is On
;***
#_EndIf
; ----------
#_If(Not_Chr_Flag)
: a5 ;(Chr0) User-created "Active Variable" 5 of the Player "Fetched" to Reference 0
: 27 ;(Flag) Flag 27
;***
;Code here is processed only if Flag (Bit) 27 of User-created "Active Variable" 5 of the Player "Fetched" to Reference 0 is Off
;***
#_Else
;***
;Code here is processed only if Flag (Bit) 27 of User-created "Active Variable" 5 of the Player "Fetched" to Reference 0 is On
;***
#_EndIf
; ----------
#_If(Obj_Flag ByReg)
: E4 ;(Obj0) "Extra Variable" 4 of the Object "Fetched" to Reference 0
: U18 ;(Reg Flag) User Register 18 contains the Flag ID
;***
;Code here is processed only if, within "Extra Variable" 4 of the Object "Fetched" to Reference 0, the Flag (Bit) whose ID is stored in User Register 18 is On
;***
#_Else
;***
;Code here is processed only if, within "Extra Variable" 4 of the Object "Fetched" to Reference 0, the Flag (Bit) whose ID is stored in User Register 18 is Off
;***
#_EndIf
; ----------
#_If(Not_Reg_Flag_ByReg) ;
: U9 ;(Reg) User Register 9
: U10 ;(Reg Flag) User Register 10 contains the Flag ID
;***
;Code here is processed only if, within User Register 9, the Flag (Bit) whose ID is stored in User Register 10 is Off
;***
#_EndIf