Headcannon Game Engine Script Commands - General
Index:
Video:
Input:
(D) (E) | _Keys_Pack |
(D) (E) | _Keys_Force |
Pause:
(D) (E) | _PauseGame_Func |
(D) (E) | _PauseGame_StatObj |
String:
(D) (E) | _String_PutChar |
(D) (E) | _String_GetChar |
(D) (E) | _ShowMessage |
Descriptions:
Video:
_Set_ScreenMode
(ALL) (REG) (Example)
Sets the Screen Mode, and automatically updates the "Screen_Mode" Register.
This Command is required for a proper mode change; updating the Register manually will have undesirable effects.
Parameters:
- Mode
The desired Screen Mode. Valid values are:
0 | - | _Screen_Single | - | Normal mode (default) |
2 | - | _Screen_Split | - | Split-Screen Mode |
The "R" or "r" tags may be used to obtain value from a Register.
Input:
_Keys_Pack
(ALL) (Example)
Obtains the "Held" keystates of the specified Key Map, and stores them as a bitfield in the given Register.
A variable may only contain 32 flags, so if a Key Map is greater in size than 32 keys, only keys 0-31 will be retrieved.
Key states are stored in from least-significant-bit to most-significant bit; Bit 0 represents Key Map entry 0,Bit 1 represents entry 1, etc.
This Command can be used in conjunction with _Keys_Force to clone keypresses, or to play back a keylog.
Parameters:
- Map
The Key Map whose states should be obtained.
The "R" or "r" tags may be used to obtain value from a Register, including the "Curr_Player" for obtaining the key states of the Map corresponding with the "Current Player".
- Var ID
The ID number of the Register that should recieve the keystates bitfield.
The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
_Keys_Force
(ALL) (Example)
Uses the bitfield stored in the given Register to manually set the "Held" keystates of the given Key Map.
A variable may only contain 32 flags, so if a Key Map is greater in size than 32 keys, only keys 0-31 can be manipulated.
Key states are stored in from least-significant-bit to most-significant bit; Bit 0 represents Key Map entry 0,Bit 1 represents entry 1, etc.
This Command can be used in conjunction with _Keys_Pack to clone keypresses or to play back a keylog, or by itself to script keypresses for "puppet scenes", AI, etc.
Parameters:
- Map
The Key Map whose states should be set.
The "R" or "r" tags may be used to obtain value from a Register, including the "Curr_Player" for obtaining the key states of the Map corresponding with the "Current Player".
- Var ID State
The ID number of the Register that contains the bitfield whose settings should be applied to the given Key Map. The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
- Var ID Mask
The ID number of a Register that should be used to maintain a backup of the passed bitfields so that successive use of this
Command will generate proper "Tapped" keystates.
The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
Pause:
_PauseGame_Func
_PauseGame_StatObj
(ALL) (Example)
Manually setting the "GamePaused" Register suspends all
Objects and Functions, which would leave the program in an inescapable pause.
These Commands assign either a Game Function or a Status Object to run
during the "pause" so that the user can be provided with a way to disable the pause (by having "GamePaused" set back
to 0), and so that the game can still perform certain actions, such as providing a "pause menu" and/or controls such as frame-stepping.
Parameters:
- Func/Script ID
In the case of Game Functions, this is the ID of the "Game Def" or "Zone Def" Function to run during the "pause". The
"G" and "Z" tags can be used to reference Functions loaded as Game-global or "Zone"-specific, respectively.
In the case of Status Object, this is the ID of the Status Script to spawn and run during the "pause". The
"G", "Z", and "A" tags can be used to reference Status Scripts loaded as Game-global, "Zone"-specific, or "Act"-specific, respectively.
String:
_String_PutChar
(ALL) (REG) (Example)
Write the given character value into the given "Game/Zone" Text at the given string position
The "R" or "r" tags
may be used to obtain a value from a Register for any Parameter
Parameters:
- Text ID
ID number of the Text string that should be modified. The "G", and "Z" tags may be used to reference
Text from the "Game Def", or the current Zone's "Zone Def", respectively
The given "Text" must have been defined within the current Game Def or Zone Def
- String Pos
The location within the Text string at which to write the given character value. The first character in the string is position "0", the second is position "1", etc.
This value must not excede the number of characters that were used to initialize the given Text
- Character
The character value that should be written to the given Text string at the given location. The character value may be entered by its ASCII Character Code, or the character itself can be entered by preceding it with a single-quote ('), such as with the following: 'a 'D '3. A closing quote is not required, but is recommended for the space character, as in: ' '
Strings are zero-terminated, so writing a "character" value of 0 will mark the current end of the string, if it should be shorter than the string that was used to initialize the given Text. As stated above, this can not be used to lengthen the string in excess of that size
_String_GetChar
(ALL) (REG) (Example)
Read a character value from the given string location within the given "Game/Zone" Text, and place it into the given Register
The "R" or "r" tags
may be used to obtain a value from a Register for any Parameter
Parameters:
- Text ID
ID number of the Text string that should be read from. The "G", and "Z" tags may be used to reference
Text from the "Game Def", or the current Zone's "Zone Def", respectively
The given "Text" must have been defined within the current Game Def or Zone Def
- String Pos
The location within the Text string from which to read the character value. The first character in the string is position "0", the second is position "1", etc.
This value must not excede the number of characters that were used to initialize the given Text
- Register ID
ID number of the Register into which the retrieved character value should be placed
The "U" tag may be used
to specify a user-defined Register. Otherwise, the ID will refer to a Game Register
_ShowMessage
(ALL) (REG) (Example)
Display the given "Game/Zone" Text through the Message System. This would generally be used for debugging, but can also be used to display other alerts during gameplay or when using a utility such as a custom-scripted editor.
Text strings that are displayed in this manner may contain Alias Names and/or Variable IDs to cause them to display the current value of a Game Register, Player Variable, or Object Variable. This is accomplished by
enclosing the Alias Name or Variable ID between two exclamation points (!). (For example, if the value of User Register 4 was "53", using this Command to display the Text string "Test: !U4!" would be displayed as "Test: 53"). In the case of Player or Object variables, the Player or Object "Fetched" to Reference 0 will be read.
Parameters:
- Text ID
ID number of the Text string that should be read from. The "G", and "Z" tags may be used to reference
Text from the "Game Def", or the current Zone's "Zone Def", respectively
The "R" or "r" tags
may be used to obtain a value from a Register
Examples:
#_Set_ScreenMode ;Set the Screen Mode to Mode 0, Single-screen
:_Screen_Single
; ----------
#_Set_ScreenMode ;Set ScreenMode (Set the Screen Mode to Mode 2, Split-screen)
:_Screen_Split
; ----------
#_Set_ScreenMode ;Set ScreenMode (Set the Screen Mode to the value stored in "User Register" 4)
: R4 ;Value stored in "User Register" 4
Input:
#_Keys_Pack ;Get the "Held" keystates for the Key Map associated with the "Current Player", and store them in "User Register" 7
: r9 ;(Map) Key Map ID stored in "Game Register" 9 (Curr_Player)
: U7 ;(Dest) "User Register" 7
; ----------
#_Keys_Pack ;Get the "Held" keystates for Key Map 3, and store them in "User Register" 5
: 3 ;(Map) Key Map 3
: U5 ;(Dest) "User Register" 5
_Keys_Force
(Description)
#_Keys_Force ;Set the "Held" keystates for Key Map 1 (also associated with Player 2) according to the bitfield stored in "User Register" 7, using the backup keystate mask stored in "User Register" 8 to generate appropriately-corresponding "Tapped" states
: 1 ;(Map) P2 Map
: U7 ;(State) "User Register" 7
: U8 ;(Mask) "User Register" 8
; ----------
#_Keys_Force ;Set the "Held" keystates for the Key Map associated with the "Current Player" according to the bitfield stored in "User Register" 5, using the backup keystate mask stored in "User Register" 6 to generate appropriately-corresponding "Tapped" states
: r9 ;(Map) Key Map ID stored in "Game Register" 9 (Curr_Player)
: U5 ;(State) "User Register" 5
: U6 ;(Mask) "User Register" 6
Pause:
#_PauseGame_Func ;Pause the game, and call Game-global Function 10 to run during the pause
: G10 ;Game-global Function 10
; ----------
#_PauseGame_StatObj ;Pause the game, and spawn Game-global Status Object 4 to run during the pause
: G4 ;Game-global Status Object 4
String:
#_String_PutChar ;Write the character value 'a' to "Game" Text 4 at string location 2
: G4 ;(Text ID) "Game" Text 4
: 2 ;(Loc) String Location 2 (the third character in the string)
: 65 ;(Char) ASCII code for 'a'
; ----------
#_String_PutChar ;Write the character value 'Q' to "Zone" Text 7 at string location 0
: Z7 ;(Text ID) "Zone" Text 7
: 0 ;(Loc) String Location 0 (the first character in the string)
: 'Q' ;(Char) Character 'Q'
; ----------
#_String_PutChar ;Write the character value whose ASCII code is stored in User Register 11 to the "Game" Text whose ID is stored in User Register 9 at the string location specified by the value of User Register 10
: R9 ;(Text ID) Value of User Register 9
: R10 ;(Loc) Value of User Register 10
: R11 ;(Char) Value of User Register 11
_String_GetChar
(Description)
#_String_GetChar ;Read the character value stored at string location 6 from "Game" Text 3, and store it in User Register 15
: G3 ;(Text ID) "Game" Text 3
: 6 ;(Loc) String Location 6 (the seventh character in the string)
: U15 ;(Char) "User Register" 15
; ----------
#_String_GetChar ;Read the character value stored at string location 12 from "Zone" Text 8, and store it in User Register 37
: Z8 ;(Text ID) "Zone" Text 8
: 12 ;(Loc) String Location 12 (the thirteenth character in the string)
: U37 ;(Char) "User Register" 37
; ----------
#_String_GetChar ;Read the character value stored at the string location given by the value of User Register 22 from the "Game" Text whose ID is stored in User Register 21, and store it in User Register 23
: R21 ;(Text ID) Value of User Register 21
: R22 ;(Loc) Value of User Register 22
: U23 ;(Char) "User Register" 23
_ShowMessage
(Description)
#_ShowMessage ;Display "Game" Text 6 through the Message System
: G6 ;(Text ID) "Game" Text 6
; ----------
#_String_GetChar ;Display "Zone" Text 2 through the Message System
: Z2 ;(Text ID) "Zone" Text 2
; ----------
#_String_GetChar ;Display the Text whose ID is stored in User Register 14 through the Message System
: R14 ;(Text ID) Value of User Register 14