Skip to content

Instantly share code, notes, and snippets.

@Jomy10
Created May 9, 2022 15:47
Show Gist options
  • Save Jomy10/573a57f0d023ddd79ad2a666a7e7e122 to your computer and use it in GitHub Desktop.
Save Jomy10/573a57f0d023ddd79ad2a666a7e7e122 to your computer and use it in GitHub Desktop.
Create RPG Maker MV Plugins

Creating RPG Maker MV Plugins

(incomplete tutorial)

Your first plugin

/*:
* @author Me
* @plugindesc This plugin outputs hello world
*
* @help
* This plugin just outputs hello world, that's it.
*/

console.log("Hello World");

Open the console in your game by pressing f8 and see the message.

You should wrap your plugin in a self-calling function so that no other plugins can access the contents of your plugin and you can't overwrite their content. If you want something that is accessible from outside of a plugin, put it outside of the function.

(function() {
  // your code goes here
  console.log("hello world");
})();

Best practices

To make sure other plugins can check if your plugin is imported (maybe they depend on your plugin), add the following to your plugin (outside of any functions):

var Imported = Imported || {};
Imported.Author_PluginName = true;

// You can use this object to namespace your plugin functions if they are accessible to other plugins
// Replace Author with your username
var Author = Author || {};
var Author.PluginName = Author.PluginName || {};
Author.PluginName.version = 1.30;
// Function
Author.PluginName.greet = function(name) {
  console.log(`Hello ${name}`);
};
// Class definition
Author.PluginName.Greeter = class {
  constructor(name) { this.name = name; }
  greet() { 
    console.log(`Hello ${this.name}`); 
  }
};
// A class instance.
// Best practice: add a $ before the name (like RPG Maker does in its source code)
Author.PluginName.$standardGreeter = new Author.PluginName.Greeter("World");

Useful overwrites

Game loop

let update = Window_Base.prototype.update;
Window_Base.prototype.update = function() {
  update.call(this);
  
  // Your code that will be called every frame
}

On map load

let onMapLoad = Scene_Map.prototype.onMapLoaded;
Scene_Map.prototype.onMapLoaded = function() {
  onMapLoad.call(this);
 
  // Your code that will be called when a map is loaded
  // Useful for setup, like parsing event notes
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment