Engine02 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:
| 356 | (D) (E) | Func_If_Reg_Flag |
| 357 | (D) (E) | Func_If_Not_Reg_Flag |
| 358 | (D) (E) | Func_If_Chr_Flag |
| 359 | (D) (E) | Func_If_Not_Chr_Flag |
| 360 | (D) (E) | Func_If_Obj_Flag |
| 361 | (D) (E) | Func_If_Not_Obj_Flag |
| 1409 | (D) (E) | Func_If_Reg_Flag_ByReg |
| 1410 | (D) (E) | Func_If_Not_Reg_Flag_ByReg |
| 1411 | (D) (E) | Func_If_Chr_Flag_ByReg |
| 1412 | (D) (E) | Func_If_Not_Chr_Flag_ByReg |
| 1413 | (D) (E) | Func_If_Obj_Flag_ByReg |
| 1414 | (D) (E) | Func_If_Not_Obj_Flag_ByReg |
Descriptions:
Flag Test IFs:
356 - Func_If_Reg_Flag
357 - Func_If_Not_Reg_Flag
358 - Func_If_Chr_Flag
359 - Func_If_Not_Chr_Flag
360 - Func_If_Obj_Flag
361 - Func_If_Not_Obj_Flag
1409 - Func_If_Reg_Flag_ByReg
1410 - Func_If_Not_Reg_Flag_ByReg
1411 - Func_If_Chr_Flag_ByReg
1412 - Func_If_Not_Chr_Flag_ByReg
1413 - Func_If_Obj_Flag_ByReg
1414 - Func_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
356 - Func_If_Reg_Flag
357 - Func_If_Not_Reg_Flag
358 - Func_If_Chr_Flag
359 - Func_If_Not_Chr_Flag
360 - Func_If_Obj_Flag
361 - Func_If_Not_Obj_Flag
1409 - Func_If_Reg_Flag_ByReg
1410 - Func_If_Not_Reg_Flag_ByReg
1411 - Func_If_Chr_Flag_ByReg
1412 - Func_If_Not_Chr_Flag_ByReg
1413 - Func_If_Obj_Flag_ByReg
1414 - Func_If_Not_Obj_Flag_ByReg
(Description)
# 356 ;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
;***
# 64 ;EndIf
; ----------
# 359 ;If Not Chr0 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
;***
# 63 ;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
;***
# 64 ;EndIf
; ----------
#1413 ;If Obj0 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
;***
# 63 ;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
;***
# 64 ;EndIf
; ----------
#1410 ;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
;***
# 64 ;EndIf