Hello, users of RPG Maker MV and MZ! It's your friendly neighbourhood Trihan here with another pointless infodump you'll likely never use for anything. You might have been using RM for a while, and be a dab hand at creating events, but have you ever stopped to wonder how they actually work? What makes them do what they do? Of course you haven't, but today we're going to look at the interpreter anyway!
Game_Interpreter is the driving force behind everything your events do, and there are a few places in the engine that have one: Game_Troop, Game_Map, Game_CommonEvent (when set to parallel process and the activation switch is on), and Game_Event (when set to parallel process). That's right, the reason parallel process events don't interrupt regular play is because they aren't handled by the map interpreter at all--they have their own!
Now let's have a look at how the interpreter works in general.
First thing to note is that every time you call a common event in an event, it sets up a child interpreter one level of depth below the current one. There is a hardcoded limit of 100 depth; if you try to call more than 99 common events in a single event, the engine will give you an error: "Common event calls exceeded the limit".
The next thing to note is that as part of event setup, if the event command is "Show Text" or "Show Picture", the face or picture graphic are preloaded; this makes sure that the image will actually be displayed on execution.
Now internally, the entire set of event commands that are created in the map .json when you create and confirm the event are stored in a property called _list, which is passed as an object array to the interpreter setup. Each individual command is an unnamed object with several properties: indent, code, and parameters. Indent determines the depth of the command (not the same as the common event depth above); code determines which command the object is for; and parameters is an array of the data required to execute the command. There is generally a distinct parameter value for every user-editable input on the event command dialogue. For example, in Show Text, the parameters and their index for MZ are: face graphic (0), face index (1), background type (2), position type (3), speaker name (4). You'll note that this doesn't include text, and that's because the text is actually stored as a separate command with a different code, and that command's parameters contain the text.
Each event command in the code is named "command(code)", so that the correct one can be dynamically called just by concatenating the code to the "command" string and then calling the function matching that name.
But that's a whole bunch of text with not much payoff, so why don't we enlighten you as to what each command's code is and what parameters it sends?
Show Text (command101)
0 - face graphic, 1 - face index, 2 - background type, 3 - position type, 4 - speaker name
Text Contents (401, processed by command101 and has no function of its own)
0 - text
Show Choices (command102)
0 - choice list (array), 1 - cancel type, 2 - default type, 3 - position type, 4 - background type
** (command402)
This function is what handles the individual branches of the defined choices.
When Cancel (command403)
This function handles the "cancel" case if you select "branch" as the cancel option.
Input Number (command103)
0 - Variable ID, 1 - number of digits
Select Item (command104)
0 - Variable ID, 1 - item type
Show Scrolling Text (command105)
0 - Scroll speed, 1 - no fast forward (boolean)
Scrolling Text Contents (405, processed by command105 and has no function of its own)
0 - text
Comment (command108)
0 - first line of comment
Further comment lines (408, processed by command108 and has no function of its own)
0 - current comment line
Skip (command109)
No parameters, MZ only (this handles the new "toggle skip" option)
Conditional Branch (command111)
0 - branch type, 1-4 - context-sensitive parameters with functions dependent on branch type
Else (command411)
No parameters, this function just handles an else branch in a conditional branch.
Loop (command112)
No parameters.
Repeat Above (command413)
No parameters, this just marks the other end of a loop.
Break Loop (command113)
No parameters.
Exit Event Processing (command115)
No parameters.
Common Event (command117)
0 - Common Event ID
Label (command118)
0 - name of label, not used in the function itself
Jump to Label (command119)
0 - name of label, used to match parameter 0 from command 118.
Control Switches (command121)
0 - Single switch ID or starting ID, 1 - range end ID, 2 - operation
Control Variables (command122)
0 - Single variable ID or starting ID, 1 - range end ID, 2 - operation, 3 - operand, 4-6 - context-sensitive parameters with functions dependent on operand
Control Self Switch (command123)
0 - Self switch letter, 1 - operation
Control Timer (command124)
0 - Operation, 1 - time in seconds
Although the input separates minutes and seconds, when confirmed it converts the minutes into seconds and then multiplies by 60 to pass the value as frames instead.
Change Gold (command125)
0 - Operation, 1 - operand, 2 - constant value or variable ID
Change Items (command126)
0 - Item ID, 1 - operation, 2 - operand, 3 - constant value or variable ID
Change Weapons (command127)
0 - Weapon ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - include equipment flag
Change Armors (command128)
0 - Armor ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - include equipment flag
Change Party Member (command129)
0 - Actor ID, 1 - operation, 2 - initialize flag
Change Battle BGM (command132)
This function only has a single parameter that's passed as an object:
{ name: BGM filename, volume: 0-100, pitch: 50-150, pan: -100-100 }
Change Victory ME (command133)
As above.
Change Save Access (command134)
0 - Disable/enable
Change Menu Access (command135)
As above.
Change Encounter (command136)
As above.
It's worth noting that immediately after this command executes, the engine recalculates how many steps it will be until the next battle happens.
Change Formation Access (command137)
As command134.
Change Window Color (command138)
0 - the tone as an RGB array.
Change Defeat ME (command139)
As command132.
Change Vehicle BGM (command140)
0 - Vehicle type ID, 1 - BGM object as above.
Transfer Player (command201)
0 - transfer type (direct designation/designation with variables), 1 - map ID or variable ID for map, 2 - x coordinate or variable ID for x, 3 - y coordinate or variable ID for y, 4 - transfer direction, 5 - fade type
Set Vehicle Location (command202)
0 - Vehicle type ID, 1-4 - as 0-3 above
Set Event Location (command203)
0 - Event ID, 1 - transfer type, 2-3 - as 2-3 in command201 OR ID of event to exchange with, 4 - transfer direction
Scroll Map (command204)
0 - Scroll direction, 1 - distance, 2 - speed, 3 - wait flag
Set Movement Route (command205)
0 - Character ID, 1 - move route list
The list contains all of the movement commands as well as the repeat/skip/wait flags. The processing itself is all handled by the Game_Event.
Get on/off Vehicle (command206)
No parameters.
Change Transparency (command211)
0 - Transparency on/off
Show Animation (command212)
0 - Character ID, 1 - animation ID, 2 - wait flag
Show Balloon Icon (command213)
0 - Character ID, 1 - balloon ID, 2 - wait flag
Erase Event (command214)
No parameters.
Change Player Followers (command216)
0 - Player followers on/off
Gather Followers (command217)
No parameters.
Fadeout Screen (command221)
No parameters.
Fadein Screen (command222)
No parameters.
Tint Screen (command223)
0 - colour object (RGB, grey), 1 - duration in frames, 2 - wait flag
Flash Screen (command224)
As above.
Shake Screen (command225)
0 - Power, 1 - speed, 2 - duration in frames, 3 - wait flag
Wait (command230)
0 - Wait time in frames
Show Picture (command231)
0 - Picture number, 1 - image filename, 2 - origin, 3 - designation type, 4 - x coordinate or variable ID for x, 5 - y coordinate or variable ID for y, 6 - scale X, 7 - scale Y, 8 - opacity, 9 - blend mode
Move Picture (command232)
0-9 as above, 10 - duration, 11 - easing type, 12 - wait flag
Rotate Picture (command233)
0 - Picture number, 1 - rotate speed
Tint Picture (command234)
0 - Picture number, 1 - colour object (RGB, grey), 2 - duration, 3 - wait flag
Erase Picture (command235)
0 - Picture number
Change Weather (command236)
0 - Weather type, 1 - power, 2 - duration, 3 - wait flag
Play BGM (command241)
As command132.
Fadeout BGM (command242)
0 - Duration in frames
Save BGM (command243)
No parameters.
Resume BGM (command244)
No parameters.
Play BGS (command245)
As command132.
Fadeout BGS (command246)
0 - Duration in frames
Play ME (command249)
As command132.
Play SE (command250)
As above.
Stop SE (command251)
No parameters.
Play Movie (command261)
0 - Video filename
Change Map Name Display (command281)
0 - Map name display on/off
Change Tileset (command282)
0 - Tileset ID
Change Battle Background (command283)
0 - Battleback1, 1 - Battleback2
Change Parallax (command284)
0 - Image filename, 1 - loop horizontally flag, 2 - horizontal scroll, 3 - loop vertically flag, 4 - vertical scroll
Get Location Info (command285)
0 - Variable ID, 1 - info type, 2 - location type, 3 - x coordinate OR variable ID for x OR character ID, 4 - y coordinate OR variable ID for y
Battle Processing (command301)
0 - Designation type, 1 - troop ID OR variable ID for troop, 2 - can escape flag, 3 - can lose flag
If Win (command601)
No parameters, this just handles the win branch of Battle Processing.
If Escape (command602)
No parameters, this just handles the escape branch of Battle Processing.
If Lose (command603)
No parameters, this just handles the lose branch of Battle Processing.
Shop Processing (command302)
0 - Item type, 1 - item ID, 2 - price type, 3 - specific price value, 4 - purchase only flag
Further shop goods (605, processed by command302 but no separate function)
0 - Item type, 1 - item ID, 2 - price type, 3 - specific price value
Name Input Processing (command303)
0 - Actor ID, 1 - max characters
Change HP (command311)
0 - Actor type, 1 - actor ID or variable ID for actor, 2 - operation, 3 - operand, 4 - constant value or variable ID, 5 - allow death flag
Change MP (command312)
0-4 - As 0-4 above.
Change TP (command326)
As above.
Change State (command313)
0-2 - As 0-2 above, 3 - state ID
Recover All (command314)
0 - Actor type, 1 - actor ID or variable ID for actor
Change Exp (command315)
0-4 - as 0-4 in command311, 5 - show level up flag
Change Level (command316)
As above.
Change Parameter (command317)
0 - Actor type, 1 - actor ID or variable ID for actor, 2 - param ID, 3 - operation, 4 - operand, 5 - constant value or variable ID
Change Skill (command318)
0-2 - as 0-2 in command311, 3 - skill ID
Change Equipment (command319)
0 - Actor ID, 1 - equipment type, 2 - item ID
Change Name (command320)
0 - Actor ID, 1 - name
Change Class (command321)
0 - Actor ID, 1 - class ID, 2 - save EXP flag
Change Actor Images (command322)
0 - Actor ID, 1 - walking graphic filename, 2 - walking graphic index, 3 - face filename, 4 - face index, 5 - battler filename
Change Vehicle Image (command323)
0 - Vehicle ID, 1 - image filename, 2 - image index
Change Nickname (command324)
0 - Actor ID, 1 - nickname
Change Profile (command325)
0 - Actor ID, 1 - profile text
Change Enemy HP (command331)
0 - Enemy ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - allow death flag
Change Enemy MP (command332)
0-3 - As 0-3 above.
Change Enemy TP (command342)
As above.
Change Enemy State (command333)
0 - Enemy ID, 1 - operation, 2 - state ID
Enemy Recover All (command334)
0 - Enemy ID
Enemy Appear (command335)
0 - Enemy index
Enemy Transform (command336)
0 - Enemy index, 1 - enemy ID to transform into
Show Battle Animation (command337)
0 - Enemy index, 1 - animation ID, 2 - entire troop flag
Force Action (command339)
0 - Subject type, 1 - actor ID or enemy ID, 2 - skill ID, 3 - target index
Abort Battle (command340)
No parameters.
Open Menu Screen (command351)
No parameters.
Open Save Screen (command352)
No parameters.
Game Over (command353)
No parameters.
Return to Title Screen (command354)
No parameters.
Script (command355)
0 - First script line
Further script (655, handled by command355 but no separate function)
0 - Script line
Plugin Command MV (command356, deprecated)
0 - String array of parameters
Plugin Command (command357)
0 - Plugin filename, 1 - plugin command name, 2 - unused, 3 - command arguments
Phew! That took a while to write out. Hopefully you've learned something about how events work, but if you have any further questions or know something cool I haven't included here, as usual feel free to chime in! Until next time.[/code]
Game_Interpreter is the driving force behind everything your events do, and there are a few places in the engine that have one: Game_Troop, Game_Map, Game_CommonEvent (when set to parallel process and the activation switch is on), and Game_Event (when set to parallel process). That's right, the reason parallel process events don't interrupt regular play is because they aren't handled by the map interpreter at all--they have their own!
Now let's have a look at how the interpreter works in general.
First thing to note is that every time you call a common event in an event, it sets up a child interpreter one level of depth below the current one. There is a hardcoded limit of 100 depth; if you try to call more than 99 common events in a single event, the engine will give you an error: "Common event calls exceeded the limit".
The next thing to note is that as part of event setup, if the event command is "Show Text" or "Show Picture", the face or picture graphic are preloaded; this makes sure that the image will actually be displayed on execution.
Now internally, the entire set of event commands that are created in the map .json when you create and confirm the event are stored in a property called _list, which is passed as an object array to the interpreter setup. Each individual command is an unnamed object with several properties: indent, code, and parameters. Indent determines the depth of the command (not the same as the common event depth above); code determines which command the object is for; and parameters is an array of the data required to execute the command. There is generally a distinct parameter value for every user-editable input on the event command dialogue. For example, in Show Text, the parameters and their index for MZ are: face graphic (0), face index (1), background type (2), position type (3), speaker name (4). You'll note that this doesn't include text, and that's because the text is actually stored as a separate command with a different code, and that command's parameters contain the text.
Each event command in the code is named "command(code)", so that the correct one can be dynamically called just by concatenating the code to the "command" string and then calling the function matching that name.
But that's a whole bunch of text with not much payoff, so why don't we enlighten you as to what each command's code is and what parameters it sends?
Show Text (command101)
0 - face graphic, 1 - face index, 2 - background type, 3 - position type, 4 - speaker name
Text Contents (401, processed by command101 and has no function of its own)
0 - text
Show Choices (command102)
0 - choice list (array), 1 - cancel type, 2 - default type, 3 - position type, 4 - background type
** (command402)
This function is what handles the individual branches of the defined choices.
When Cancel (command403)
This function handles the "cancel" case if you select "branch" as the cancel option.
Input Number (command103)
0 - Variable ID, 1 - number of digits
Select Item (command104)
0 - Variable ID, 1 - item type
Show Scrolling Text (command105)
0 - Scroll speed, 1 - no fast forward (boolean)
Scrolling Text Contents (405, processed by command105 and has no function of its own)
0 - text
Comment (command108)
0 - first line of comment
Further comment lines (408, processed by command108 and has no function of its own)
0 - current comment line
Skip (command109)
No parameters, MZ only (this handles the new "toggle skip" option)
Conditional Branch (command111)
0 - branch type, 1-4 - context-sensitive parameters with functions dependent on branch type
Else (command411)
No parameters, this function just handles an else branch in a conditional branch.
Loop (command112)
No parameters.
Repeat Above (command413)
No parameters, this just marks the other end of a loop.
Break Loop (command113)
No parameters.
Exit Event Processing (command115)
No parameters.
Common Event (command117)
0 - Common Event ID
Label (command118)
0 - name of label, not used in the function itself
Jump to Label (command119)
0 - name of label, used to match parameter 0 from command 118.
Control Switches (command121)
0 - Single switch ID or starting ID, 1 - range end ID, 2 - operation
Control Variables (command122)
0 - Single variable ID or starting ID, 1 - range end ID, 2 - operation, 3 - operand, 4-6 - context-sensitive parameters with functions dependent on operand
Control Self Switch (command123)
0 - Self switch letter, 1 - operation
Control Timer (command124)
0 - Operation, 1 - time in seconds
Although the input separates minutes and seconds, when confirmed it converts the minutes into seconds and then multiplies by 60 to pass the value as frames instead.
Change Gold (command125)
0 - Operation, 1 - operand, 2 - constant value or variable ID
Change Items (command126)
0 - Item ID, 1 - operation, 2 - operand, 3 - constant value or variable ID
Change Weapons (command127)
0 - Weapon ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - include equipment flag
Change Armors (command128)
0 - Armor ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - include equipment flag
Change Party Member (command129)
0 - Actor ID, 1 - operation, 2 - initialize flag
Change Battle BGM (command132)
This function only has a single parameter that's passed as an object:
{ name: BGM filename, volume: 0-100, pitch: 50-150, pan: -100-100 }
Change Victory ME (command133)
As above.
Change Save Access (command134)
0 - Disable/enable
Change Menu Access (command135)
As above.
Change Encounter (command136)
As above.
It's worth noting that immediately after this command executes, the engine recalculates how many steps it will be until the next battle happens.
Change Formation Access (command137)
As command134.
Change Window Color (command138)
0 - the tone as an RGB array.
Change Defeat ME (command139)
As command132.
Change Vehicle BGM (command140)
0 - Vehicle type ID, 1 - BGM object as above.
Transfer Player (command201)
0 - transfer type (direct designation/designation with variables), 1 - map ID or variable ID for map, 2 - x coordinate or variable ID for x, 3 - y coordinate or variable ID for y, 4 - transfer direction, 5 - fade type
Set Vehicle Location (command202)
0 - Vehicle type ID, 1-4 - as 0-3 above
Set Event Location (command203)
0 - Event ID, 1 - transfer type, 2-3 - as 2-3 in command201 OR ID of event to exchange with, 4 - transfer direction
Scroll Map (command204)
0 - Scroll direction, 1 - distance, 2 - speed, 3 - wait flag
Set Movement Route (command205)
0 - Character ID, 1 - move route list
The list contains all of the movement commands as well as the repeat/skip/wait flags. The processing itself is all handled by the Game_Event.
Get on/off Vehicle (command206)
No parameters.
Change Transparency (command211)
0 - Transparency on/off
Show Animation (command212)
0 - Character ID, 1 - animation ID, 2 - wait flag
Show Balloon Icon (command213)
0 - Character ID, 1 - balloon ID, 2 - wait flag
Erase Event (command214)
No parameters.
Change Player Followers (command216)
0 - Player followers on/off
Gather Followers (command217)
No parameters.
Fadeout Screen (command221)
No parameters.
Fadein Screen (command222)
No parameters.
Tint Screen (command223)
0 - colour object (RGB, grey), 1 - duration in frames, 2 - wait flag
Flash Screen (command224)
As above.
Shake Screen (command225)
0 - Power, 1 - speed, 2 - duration in frames, 3 - wait flag
Wait (command230)
0 - Wait time in frames
Show Picture (command231)
0 - Picture number, 1 - image filename, 2 - origin, 3 - designation type, 4 - x coordinate or variable ID for x, 5 - y coordinate or variable ID for y, 6 - scale X, 7 - scale Y, 8 - opacity, 9 - blend mode
Move Picture (command232)
0-9 as above, 10 - duration, 11 - easing type, 12 - wait flag
Rotate Picture (command233)
0 - Picture number, 1 - rotate speed
Tint Picture (command234)
0 - Picture number, 1 - colour object (RGB, grey), 2 - duration, 3 - wait flag
Erase Picture (command235)
0 - Picture number
Change Weather (command236)
0 - Weather type, 1 - power, 2 - duration, 3 - wait flag
Play BGM (command241)
As command132.
Fadeout BGM (command242)
0 - Duration in frames
Save BGM (command243)
No parameters.
Resume BGM (command244)
No parameters.
Play BGS (command245)
As command132.
Fadeout BGS (command246)
0 - Duration in frames
Play ME (command249)
As command132.
Play SE (command250)
As above.
Stop SE (command251)
No parameters.
Play Movie (command261)
0 - Video filename
Change Map Name Display (command281)
0 - Map name display on/off
Change Tileset (command282)
0 - Tileset ID
Change Battle Background (command283)
0 - Battleback1, 1 - Battleback2
Change Parallax (command284)
0 - Image filename, 1 - loop horizontally flag, 2 - horizontal scroll, 3 - loop vertically flag, 4 - vertical scroll
Get Location Info (command285)
0 - Variable ID, 1 - info type, 2 - location type, 3 - x coordinate OR variable ID for x OR character ID, 4 - y coordinate OR variable ID for y
Battle Processing (command301)
0 - Designation type, 1 - troop ID OR variable ID for troop, 2 - can escape flag, 3 - can lose flag
If Win (command601)
No parameters, this just handles the win branch of Battle Processing.
If Escape (command602)
No parameters, this just handles the escape branch of Battle Processing.
If Lose (command603)
No parameters, this just handles the lose branch of Battle Processing.
Shop Processing (command302)
0 - Item type, 1 - item ID, 2 - price type, 3 - specific price value, 4 - purchase only flag
Further shop goods (605, processed by command302 but no separate function)
0 - Item type, 1 - item ID, 2 - price type, 3 - specific price value
Name Input Processing (command303)
0 - Actor ID, 1 - max characters
Change HP (command311)
0 - Actor type, 1 - actor ID or variable ID for actor, 2 - operation, 3 - operand, 4 - constant value or variable ID, 5 - allow death flag
Change MP (command312)
0-4 - As 0-4 above.
Change TP (command326)
As above.
Change State (command313)
0-2 - As 0-2 above, 3 - state ID
Recover All (command314)
0 - Actor type, 1 - actor ID or variable ID for actor
Change Exp (command315)
0-4 - as 0-4 in command311, 5 - show level up flag
Change Level (command316)
As above.
Change Parameter (command317)
0 - Actor type, 1 - actor ID or variable ID for actor, 2 - param ID, 3 - operation, 4 - operand, 5 - constant value or variable ID
Change Skill (command318)
0-2 - as 0-2 in command311, 3 - skill ID
Change Equipment (command319)
0 - Actor ID, 1 - equipment type, 2 - item ID
Change Name (command320)
0 - Actor ID, 1 - name
Change Class (command321)
0 - Actor ID, 1 - class ID, 2 - save EXP flag
Change Actor Images (command322)
0 - Actor ID, 1 - walking graphic filename, 2 - walking graphic index, 3 - face filename, 4 - face index, 5 - battler filename
Change Vehicle Image (command323)
0 - Vehicle ID, 1 - image filename, 2 - image index
Change Nickname (command324)
0 - Actor ID, 1 - nickname
Change Profile (command325)
0 - Actor ID, 1 - profile text
Change Enemy HP (command331)
0 - Enemy ID, 1 - operation, 2 - operand, 3 - constant value or variable ID, 4 - allow death flag
Change Enemy MP (command332)
0-3 - As 0-3 above.
Change Enemy TP (command342)
As above.
Change Enemy State (command333)
0 - Enemy ID, 1 - operation, 2 - state ID
Enemy Recover All (command334)
0 - Enemy ID
Enemy Appear (command335)
0 - Enemy index
Enemy Transform (command336)
0 - Enemy index, 1 - enemy ID to transform into
Show Battle Animation (command337)
0 - Enemy index, 1 - animation ID, 2 - entire troop flag
Force Action (command339)
0 - Subject type, 1 - actor ID or enemy ID, 2 - skill ID, 3 - target index
Abort Battle (command340)
No parameters.
Open Menu Screen (command351)
No parameters.
Open Save Screen (command352)
No parameters.
Game Over (command353)
No parameters.
Return to Title Screen (command354)
No parameters.
Script (command355)
0 - First script line
Further script (655, handled by command355 but no separate function)
0 - Script line
Plugin Command MV (command356, deprecated)
0 - String array of parameters
Plugin Command (command357)
0 - Plugin filename, 1 - plugin command name, 2 - unused, 3 - command arguments
Phew! That took a while to write out. Hopefully you've learned something about how events work, but if you have any further questions or know something cool I haven't included here, as usual feel free to chime in! Until next time.[/code]