A | B | C | D | E | F | G | ||
---|---|---|---|---|---|---|---|---|
1 | Script Calls | Last updated 2023-12-14 (01:50 UTC) | ||||||
2 | MV | MZ | Effect | Script call(s) | Example(s) | Inputs/Outputs | Notes | |
3 | Event Commands | Recent update log: | ||||||
4 | Page 1 | See also: | This Script Call List is being maintained by: | [Reverted 2023-12-14] 2023-11-11 (Caethyril) | ||||
5 | Page 2 | Useful Console | Archeia | Added await for MZ save/load script calls. | ||||
6 | Page 3 | Old Script Call List (may be inaccurate) | Caethyril | |||||
7 | General Script Calls | 2023-10-23 (Caethyril) | ||||||
8 | Message | Suggestions/feedback: | Corrected "Clear Image Cache (1 Entry)" [MV]. | |||||
9 | Inventory | RPG Maker MV / MZ Script Call List | Note on leading zeroes: | |||||
10 | Actors & Enemies | Do not write zeroes in front of integers! | 2023-09-25 (Caethyril) | |||||
11 | Actor/Enemy Params | Detailed technical reference (database, traits, etc): | Good: 1 | New Last Action Data section with "Last Selected Item". | ||||
12 | Classes & Skills | RPG Maker MZ Script Call Reference | Bad: 0001 | Misc small edits for clarity. | ||||
13 | Equipment | (MV is similar to MZ, but not identical.) | ||||||
14 | States, Buffs, etc | Common pitfall: this. | 2023-08-31 (Caethyril) | |||||
15 | Switches & Variables | RPG Maker VX Ace reference: | The JavaScript keyword this is context-sensitive: | Documented "Does Save File Exist?" script call. | ||||
16 | Events & Interpreters | Script Call Collection for VXAce | In a Script event command, this is... | |||||
17 | Inputs | ...the Game_Interpreter processing this event. | 2023-08-21 (Caethyril) | |||||
18 | Characters | In a Script move route command, this is... | Added "leading zeroes" note & MDN / W3Schools links. | |||||
19 | Character Properties | ...the Game_Character being moved. | ||||||
20 | Character Movement | In a damage formula, this is... | 2023-07-22 (Caethyril) | |||||
21 | Character Effects | ...the Game_Action being processed. | Added map refresh to Clear/Restore Inventory calls. | |||||
22 | Map Properties | RPG Maker Web: | In other contexts, the value of this may vary. | |||||
23 | Screen FX & Pictures | Learning JavaScript | 2023-06-15 (Caethyril) | |||||
24 | Scenes | Note on functions: | Corrected Enable/Disable map name display script calls. | |||||
25 | Save & Continue | RMMV scripting tutorials, by Trihan: | $gamePlayer.direction | Copied basic Change HP calls to "Commands" section. | ||||
26 | Timer & System | Jump into JavaScript | ...returns a reference to the function. | |||||
27 | Audio & Video | The anatomy of a plugin | $gamePlayer.direction() | 2023-04-09 (Caethyril) | ||||
28 | Battle | ...evaluates the function and returns a number (direction). | Corrected error in Memorise Party Members script call. | |||||
29 | Last Action Data | Plugin Creation Tutorial: | MDN JS Functions tutorial | |||||
30 | Damage Formula | RPG Maker MZ Plugin Creation Tutorial | 2023-01-15 (Caethyril) | |||||
31 | Cache Management | Documented Event Editor Reference. | ||||||
32 | Plugins | Other links: | Documented Troop Database Record. | |||||
33 | Plugin Header | LunaTechs Intellisense for MV/MZ | Added a few examples. | |||||
34 | Plugin Header: Types | MDN | W3 Schools | ||||||
35 | Plugin Code | NWJS docs | 2022-10-30 (Archeia) | |||||
36 | Plugin Code: Style | PixiJS | Added new sheet QoL and updated VisuStella sheet. | |||||
37 | ||||||||
38 | Event Commands | Script calls for event commands | ||||||
39 | Page 1 | Message, Party, Actor, Game Progression, Flow Control | ▲ Return to top ▲ | |||||
40 | Message | |||||||
41 | Show Text | $gameMessage.setFaceImage(faceName, faceIndex); $gameMessage.setBackground(bgType); $gameMessage.setPositionType(posType); $gameMessage.setSpeakerName(speakerName); $gameMessage.add(text); interpreter.setWaitMode('message'); | // Set face: Actor1.png, index 0 $gameMessage.setFaceImage('Actor1', 0); // Set background: Window $gameMessage.setBackground(0); // Set position: Bottom $gameMessage.setPositionType(2); // [MZ] Set speaker name: \c[6]\n[1] $gameMessage.setSpeakerName('\\c[6]\\n[1]'); // Show text: I am \c[6]\n[1]\c[0]! $gameMessage.add('I am \\c[6]\\n[1]\\c[0]!'); // Wait for message to be dismissed this.setWaitMode('message'); | String faceName • Name of the faceset to use. Number faceIndex • Index of face. Use 0 for face #1. Number bgType • 0 (Window), 1 (Dim), or 2 (Transparent). Number posType • 0 (Top), 1 (Middle), or 2 (Bottom). String speakerName [MZ only] • Sets the name box text. String text • Message text! Game_Interpreter interpreter • Interpreter reference (this in a Script command). | In JavaScript, \backslash is used for escape notation, e.g. "\n" for a new line: String escape sequences. For an actual backslash, use "\\" like in the example. The final line with setWaitMode pauses the interpreter until the message is dismissed. If you have follow-up commands (e.g. Show Choices or Input Number) then you can put setWaitMode after those instead. | |||
42 | $gameMessage.setFaceImage(faceName, faceIndex); $gameMessage.setBackground(bgType); $gameMessage.setPositionType(posType); $gameMessage.add(text); interpreter.setWaitMode('message'); | |||||||
43 | Show Choices | $gameMessage.setChoices(choices, defaultIndex, cancelIndex); $gameMessage.setChoiceBackground(bgType); $gameMessage.setChoicePositionType(posType); $gameMessage.setChoiceCallback(callback); interpreter.setWaitMode('message'); | // Set choices to A, B, C; default C, no cancel $gameMessage.setChoices(['A', 'B', 'C'], 2, -1); // Set background: Dim $gameMessage.setChoiceBackground(1); // Set position: Center $gameMessage.setChoicePositionType(1); // On choice, set variable #1 equal to the selected index $gameMessage.setChoiceCallback(n => { $gameVariables.setValue(1, n); }); // Wait for a choice to be selected this.setWaitMode('message'); | String[] choices • Array of choice texts to show, in order. Number defaultIndex • Starting choice index (0 for choice #1). Number cancelIndex • Cancel selects this index (-1 for no cancel). • Use -2 for "Branch" cancel type. Number bgType • 0 (Window), 1 (Dim), or 2 (Transparent). Number posType • 0 (Left), 1 (Center), or 2 (Right). Function callback • 1 argument: selected choice index. • Gets called when a choice is made. • Runs in Game_Interpreter context. Game_Interpreter interpreter • Interpreter reference (this in a Script command). | You can use as many choices as you like: the window will scroll if necessary. Remember that choice #1 is index 0, #2 is index 1, etc. setWaitMode is important here. | |||
44 | Input Number | $gameMessage.setNumberInput(variableId, maxDigits); interpreter.setWaitMode('message'); | // Input a 5-digit number; store result in variable #1 $gameMessage.setNumberInput(1, 5); // Wait for input to be confirmed this.setWaitMode('message'); | Number variableId • ID of the variable used to store input. Number maxDigits • Number of digits to show. Game_Interpreter interpreter • Interpreter reference (this in a Script command). | setWaitMode is important here. | |||
45 | Select Item | $gameMessage.setItemChoice(variableId, itemType); interpreter.setWaitMode('message'); | // Select a Key item; store that item's ID in variable #1 $gameMessage.setItemChoice(1, 2); // Wait for an item to be selected this.setWaitMode('message'); | Number variableId • ID of the variable to store selected item's ID. Number itemType • 1 (Normal), 2 (Key), 3 (Hidden A), or 4 (Hidden B). Game_Interpreter interpreter • Interpreter reference (this in a Script command). | setWaitMode is important here. | |||
46 | Show Scrolling Text | $gameMessage.setScroll(scrollSpeed, noFast); $gameMessage.add(text); interpreter.setWaitMode('message'); | // Write out the story text var text = [ 'People have been coming to the wise man,', 'complaining about the same problems every time.\n', 'One day he told them a joke and everyone roared', 'in laughter.\n', 'After a couple of minutes, he told them the same joke', 'and only a few of them smiled.\n', 'When he told the same joke for the third time no one', 'laughed anymore.\n', 'The wise man smiled and said:', '"You can’t laugh at the same joke over and over.', 'So why are you always crying about the same problem?"' ].join('\n'); // Set the message to scroll mode, speed 3, can fast-forward $gameMessage.setScroll(3, false); // Add the story to the message $gameMessage.add(text); // Wait for scrolling text to end this.setWaitMode('message'); | Number scrollSpeed • Normally 1~8. Boolean noFast • If true, the player cannot fast-forward it. String text • Message text! Game_Interpreter interpreter • Interpreter reference (this in a Script command). | See the setWaitMode note for Show Text. You can use "\n" for a new line. The example uses the Array#join method to merge a list of text lines into a single, multi-line string. More information here: Array#join. | |||
47 | ||||||||
48 | Party | |||||||
49 | Change Gold (Add) | $gameParty.gainGold(amount); | // Give the party +1000 gold $gameParty.gainGold(1000); | Number amount • Quantity to add/remove (can be negative). | - | |||
50 | Change Gold (Remove) | $gameParty.loseGold(amount); | // Remove 500 gold from the party $gameParty.loseGold(500); | |||||
51 | Change Items (Add) | $gameParty.gainItem(item, amount); | // Give the party 5x Item ID 1 $gameParty.gainItem($dataItems[1], 5); | $dataItem item • Database item reference Number amount • Quantity to add/remove (can be negative). | - | |||
52 | Change Items (Remove) | $gameParty.loseItem(item, amount); | // Remove up to 1 of Item 12 from the party inventory $gameParty.loseItem($dataItems[12], 1); | |||||
53 | Change Weapons (Add) | $gameParty.gainItem(weapon, amount); | // Give the party 1x Weapon ID 1 $gameParty.gainItem($dataWeapons[1], 1); | $dataWeapon weapon • Database weapon reference. Number amount • Quantity to add/remove (can be negative). Boolean includeEquip • If true, equipped weapons can be removed. | Equipped weapons/armors can only be removed if there are not enough of that item in inventory. | |||
54 | Change Weapons (Remove) | $gameParty.loseItem(weapon, amount, includeEquip); | // Remove up to 99 of Weapon 2, including equipped items $gameParty.loseItem($dataWeapons[2], 99, true); | |||||
55 | Change Armors (Add) | $gameParty.gainItem(armor, amount); | // Give the party 2x Armor ID 1 $gameParty.gainItem($dataArmors[1], 2); | $dataArmor armor • Database armor reference. Number amount • Quantity to add/remove (can be negative). Boolean includeEquip • If true, equipped armors can be removed. | ||||
56 | Change Armors (Remove) | $gameParty.loseItem(armor, amount, includeEquip); | // Remove up to 5 of Armor 2, ignoring equipped items $gameParty.loseItem($dataArmors[2], 5); | |||||
57 | Change Party Member (Add) | $gameParty.addActor(actorId); | // Add actor ID 4 to the party $gameParty.addActor(4); | Number actorId • ID of the actor to add/remove. | If used in battle you may need to refresh the battle status window to match the new party setup. | |||
58 | Change Party Member (Remove) | $gameParty.removeActor(actorId); | // Remove actor ID 1 from the party $gameParty.removeActor(1); | |||||
59 | ||||||||
60 | Actor | |||||||
61 | Change HP | target.setHp(value); | // Set the HP of party member #2 (first follower) to 50% var actor = $gameParty.members()[1]; actor.setHp(actor.mhp / 2); | Game_Interpreter interpreter • Interpreter reference (this in a Script command). Game_Battler battler • The actor or enemy to gain/lose HP. Number value • Amount of HP to gain (can be negative). Boolean allowKO • If true, the target can die. | - | |||
62 | target.gainHp(value); | // Heal 50 HP for actor ID 1 $gameActors.actor(1).gainHp(10); | ||||||
63 | interpreter.changeHp(target, value, allowKO); | // In a Script command: 100 damage to party leader, allow KO this.changeHp($gameParty.members()[0], -100, true); | No effect if the target is dead. The collapse effect will start if the target dies in battle. Works for actors or enemies. | |||||
64 | Game_Interpreter.prototype.changeHp.call( this, target, value, allowKO ); | // Heal 50 HP for actor ID 1 Game_Interpreter.prototype.changeHp.call( this, $gameActors.actor(1), 50, false ); | ||||||
65 | Change MP | battler.gainMp(value); | // Make actor ID 2 lose 20 MP $gameActors.actor(2).gainMp(-20); | Game_Battler battler • The actor or enemy to gain/lose MP. Number value • Amount of MP to gain (can be negative). | Works for actors or enemies. | |||
66 | // Restore +10% MP for the party leader var actor = $gameParty.members()[0]; actor.gainMp(0.1 * actor.mmp); | |||||||
67 | Change TP | battler.gainTp(value); | // Make party member #3 (index 2) gain 100 TP $gameParty.members()[2].gainTp(100); | Game_Battler battler • The actor or enemy to gain/lose TP. Number value • Amount of TP to gain (can be negative). | Works for actors or enemies. | |||
68 | // Make the party leader lose 10 TP $gameParty.members()[0].gainTp(-10); | |||||||
69 | Change State (Add) | battler.addState(stateId); | // Add state ID 1 to the party leader and check for collapse var target = $gameParty.members()[0]; var isDead = target.isDead(); target.addState(1); if (!isDead && target.isDead()) target.performCollapse(); | Game_Battler battler • The actor or enemy to gain/lose the state. Number stateId • ID of the state to add/remove. | In some situations, adding/removing a state can cause the target to die/revive, e.g. • Add state 1; • Remove a state with a "Resist State 1" trait at 0 HP. In these cases it is recommended to use the "check for collapse" version to ensure the collapse effect plays at the correct time. Works for actors or enemies. | |||
70 | var target = battler; var isDead = target.isDead(); target.addState(stateId); if (!isDead && target.isDead()) target.performCollapse(); | |||||||
71 | Change State (Remove) | battler.removeState(stateId); | // Remove state ID 6 from actor ID 2, no collapse check $gameActors.actor(2).removeState(6); | |||||
72 | var target = battler; var isDead = target.isDead(); target.removeState(stateId); if (!isDead && target.isDead()) target.performCollapse(); | |||||||
73 | Recover All (One) | battler.recoverAll(); | // Make actor ID 1 fully recover $gameActors.actor(1).recoverAll(); | Game_Battler battler • The actor or enemy to be fully recovered. | Removes all states and sets HP & MP to maximum. | |||
74 | Recover All (Entire Party) | $gameParty.members().forEach(function(actor) { actor.recoverAll(); }); | - | - | If used in battle, this will only affect the battle members. | |||
75 | Change EXP | actor.gainExp(value); | // Give +1000 EXP to the party leader $gameParty.members()[0].gainExp(1000); | Game_Actor actor • The actor to gain/lose EXP. Number value • Amount of EXP to gain (can be negative). | Level-up messages will be shown if appropriate. | |||
76 | // Remove 500 EXP from actor ID 2 $gameActors.actor(2).gainExp(-500); | |||||||
77 | Change Level | actor.changeLevel(level, show); | // Set the party leader to level 5 $gameParty.members()[0].changeLevel(5, true); | Game_Actor actor • The actor to change level. Number level • New level. Boolean show • If true, show level-up message(s). | - | |||
78 | // Silently increase the level of actor ID 2 by +1 var actor = $gameActors.actor(2); actor.changeLevel(actor.level + 1, false); | |||||||
79 | Change Parameters | battler.addParam(paramId, value); | // Give the party leader a permanent +10 ATK bonus $gameParty.members()[0].addParam(2, 10); | Game_Battler battler • The one to gain/lose the basic param bonus. Number paramId • Basic parameter ID (see notes ->). Number value • Bonus to add (can be negative). | Basic parameters are calculated as: (Base + Plus) * TraitRate * BuffRate addParam increases/decreases the Plus value. For actors, Plus is also affected by equipment. Basic parameter IDs: • 0 = MHP • 1 = MMP • 2 = ATK • 3 = DEF • 4 = MAT • 5 = MDF • 6 = AGI • 7 = LUK Works for actors or enemies. | |||
80 | // Give actor ID 5 a permanent -20 LUK $gameActors.actor(5).addParam(7, -20); | |||||||
81 | Change Skill | actor.learnSkill(skillId); | // Make the party leader learn skill ID 25 $gameParty.members()[0].learnSkill(25); | Game_Actor actor • The one to learn/forget the skill. Number skillId • New skill ID. | - | |||
82 | actor.forgetSkill(skillId); | // Make actor ID 2 forget skill 7 $gameActors.actor(2).forgetSkill(7); | ||||||
83 | Change Equipment | actor.changeEquipById(etypeId, itemId); | // Equip weapon/armor ID 5 in the party leader's first equip slot $gameParty.members()[0].changeEquipById(1, 5); | Game_Actor actor • The one to (un)equip the item. Number etypeId • Equipment Type ID: 1 = first slot. Number itemId • ID of the item to equip. | Equipment Types are defined on the Types tab in the database. | |||
84 | Change Name | actor.setName(name); | // Rename the party leader to Leader $gameParty.members()[0].setName('Leader'); | Game_Actor actor • The one to rename. String name • Their new name. | - | |||
85 | // Set the name of actor 2 equal to the name of actor 1 $gameActors.actor(2).setName($gameActors.actor(1).name()); | |||||||
86 | Change Class | actor.changeClass(classId, keepExp); | // Change the party leader to class ID 3, keeping previous EXP $gameParty.members()[0].changeClass(3, true); | Game_Actor actor • The one to change class. Number classId • New class ID Boolean keepExp • If false, reset EXP to 0. | - | |||
87 | // Make actor 1 change to class 1 with 0 EXP $gameActors.actor(1).changeClass(1, false); | |||||||
88 | Change Nickname | actor.setNickname(nickname); | // Set the party leader's nickname to Superhero $gameParty.members()[0].setNickname('Superhero'); | Game_Actor actor • The one to rename. String nickname • New nickname. | - | |||
89 | Change Profile | actor.setProfile(profile); | // Set the party leader's profile to Here is some profile text. $gameParty.leader.setProfile('Here is some profile text.'); | Game_Actor actor • The one to change profile. String profile • New profile. | - | |||
90 | // Add to the end of actor 2's profile var actor = $gameActors.actor(2); var text = actor.profile() + '\n\nSome text.'; actor.setProfile(text); | |||||||
91 | ||||||||
92 | Game Progression | |||||||
93 | Control Switches | $gameSwitches.setValue(switchId, value); | // Turn on switch ID 1 $gameSwitches.setValue(1, true); | Number switchId • ID of switch to change. Boolean value • true (ON) or false (OFF). | - | |||
94 | // Turn off switch ID 5 $gameSwitches.setValue(5, false); | |||||||
95 | Control Variables | $gameVariables.setValue(variableId, value); | // Set variable ID 1 equal to 5 $gameVariables.setValue(1, 5); | Number variableId • ID of variable to change. Any value • Operand value (can be negative). | Variables can store any value, including: • String • Array Numerical results will be rounded down to the nearest integer. Non-stringifiable data will be lost on save/load, more info here: JSON.stringify. | |||
96 | Control Variables (Add) | $gameVariables.setValue(variableId, $gameVariables.value(variableId) + value); | // +10 to variable ID 1 $gameVariables.setValue(1, $gameVariables.value(1) + 10); | Number variableId • ID of variable to change. Number value • Operand (can be negative) | Also works for strings, e.g. • "cheese" + "cake" = "cheesecake" | |||
97 | Control Variables (Sub) | $gameVariables.setValue(variableId, $gameVariables.value(variableId) - value); | // -10 to variable ID 1 $gameVariables.setValue(1, $gameVariables.value(1) - 10); | - | ||||
98 | Control Variables (Mul) | $gameVariables.setValue(variableId, $gameVariables.value(variableId) * value); | // Multiply variable ID 1 by 5 $gameVariables.setValue(1, $gameVariables.value(1) * 5); | - | ||||
99 | Control Variables (Div) | $gameVariables.setValue(variableId, $gameVariables.value(variableId) / value); | // Divide variable ID 1 by 2 $gameVariables.setValue(1, $gameVariables.value(1) / 2); | In JavaScript, div by 0 returns the special value Infinity. | ||||
100 | Control Variables (Mod) | $gameVariables.setValue(variableId, $gameVariables.value(variableId).mod(value)); | // Store the +remainder after dividing variable ID 1 by 12 $gameVariables.setValue(1, $gameVariables.value(1).mod(12)); | For modular arithmetic. Common uses: • Get digits of a number, e.g. mod 10 to get units digit • Cyclic calculations, e.g. time of day |