Headcannon Game Engine Script Commands - If Conditionals (General)
"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:
If Terminators:
(D) (E) | _Else |
(D) (E) | _EndIf |
File Conditions:
(D) (E) | _If(FileOpen) |
(D) (E) | _If(FileEOF) |
Miscellaneous Conditions:
(D) (E) | _If(KeyState) |
(D) (E) | _If(Object_Range) |
Descriptions:
If Terminators:
_Else
(ALL) (Example)
Signifies an "Else" Block to complement an "If" Block. If the "If" condition
wasn't satisfied, the Commands in the "Else" Block are processed
Parameters:
None
_EndIf
(ALL) (Example)
Signifies the end of "If" and "Else" Blocks. All "If/Else" blocks must be
terminated with an "EndIf" Command. If an "If Block" contains an "Else", the "Else" marks the end
of the "If", and the "EndIf" marks the end of the "Else"
Parameters:
None
File Conditions:
_If(FileOpen)
(ALL) (Example)
"If" condition performed on the "opened" state of User-Manged Files, to determine whether or not a file of the given access type is currently open
Parameters:
- Access
Specifies the access type of the file that should be tested:
0 | - | _FileType_Read | - | Test the file that is currently open for Read access |
1 | - | _FileType_Write | - | Test the file that is currently open for Write access |
- Condition
0 | - | _False | - | Test if the given file failed to open, or no open attempt was made |
1 | - | _True | - | Test if the given file was opened successfully |
_If(FileEOF)
(OBJ) (Example)
"If" condition performed on the position of "opened" User-Manged Files, to determine whether or not their current file position is at the file's end
Parameters:
- Access
Specifies the access type of the file that should be tested:
0 | - | _FileType_Read | - | Test the file that is currently open for Read access |
1 | - | _FileType_Write | - | Test the file that is currently open for Write access |
- Condition
0 | - | _False | - | Test if the given file's current position is not its EOF |
1 | - | _True | - | Test if the given file's current position is its EOF |
Miscellaneous Conditions:
_If(KeyState)
(ALL) (Example)
_If(Object_Range)
(OBJ) (Example)
"If" condition performed on an Object and the Screen/Activity boundaries.
The test is based on whether or not the Object's X/Y position is within the given area
The Object being tested must be "Fetched" to Reference 0
Parameters:
- Range
During a range test, the object is tested against Screen/Activity ranges for both
players 1 and 2 if in split-screen mode. Otherwise, only player 1's screen area is tested
0 | - | _Range_Screen | - | Test object against the on-screen area |
1 | - | _Range_Activity | - | Test object against "Activity Range" |
- In/Out
0 | - | _Out | - | Test if object is outside this range |
1 | - | _In | - | Test if object is inside this range |
Examples:
If Terminators and Miscellaneous Conditions:
#_If(FileOpen)
:_FileType_Read ;(Access)
:_True ;(Open)
;***
;Code here is processed only if there is currently a file open for Read-access
;***
#_EndIf
; ----------
#_If(FileOpen)
:_FileType_Write ;(Access)
:_False ;(Open)
;***
;Code here is processed only if there is not currently a file open for Write-access
;***
#_Else
;***
;Code here is processed only if there is currently a file open for Write-access
;***
#_EndIf
; ----------
#_If(FileEOF)
:_FileType_Read ;(Access)
:_False ;(EOF)
;***
;Code here is processed only if the file that is currently open for Read-access has not reached its end
;***
#_EndIf
; ----------
#_If(FileEOF)
:_FileType_Write ;(Access)
:_True ;(EOF)
;***
;Code here is processed only if the file that is currently open for Write-access has reached its end
;***
#_EndIf
; ----------
#_If(KeyState)
: PT3 ;(Key) Current Player KeyMap, Tapped Key 3
:_On ;(On/Off)
;***
;Code here is processed only if key 3 in the KeyMap corresponding with "CurrPlayer" was tapped during this Game Frame
;***
#_EndIf
; ----------
#_If(KeyState)
:M0H1 ;(Key) KeyMap 0, Holding Key 1
:_Off ;(On/Off)
;***
;Code here is processed only if key 1 in KeyMap 0 is not being held
;***
#_EndIf
; ----------
#_If(Object_Range)
:_Range_Activity ;(Range)
:_In ;(In/Out)
;***
;Code here is processed only if the X/Y position of the Object "Fetched" to Reference 0 is inside "Activity Range"
;***
#_Else
;***
;Code here is processed only if the X/Y position of the Object "Fetched" to Reference 0 is not inside "Activity Range"
;***
#_EndIf
; ----------
#_If(Object_Range)
:_Range_Screen ;(Range)
:_Out ;(In/Out)
;***
;Code here is processed only if the X/Y position of the Object "Fetched" to Reference 0 is outside of the visible screen area
;***
#_EndIf