RPGMaker MV Plugin Patterns

Introduction

Here, I offer to you a pattern for creating plugins in RPGMaker MV, which you can use in any of your projects as a base for a plugin, that’s extendable, and allows you to create multiple plugins under a single namespace.

Code Example

Code Example Breakdown

Comment Section [ Line 6 – 36]

On line 6, you notice it starts with “/*:”; in RPGMaker MV plugins, this is the start of the plugin parameters section. The “plugin parameters section”, is where you can define who the author is, a description of the plugin, parameters that the plugin can get from the user, and help information. These are all within the lines 6 – 36.

Namespace [39 – 45]

Starting on this line, we start creating our namespace; the namespace is a place to hold all of our code for our sets of plugins, or helpers for the developer. This is so we can encapsulate — keep our code private from other plugin developers, so that we don’t break their code or our own.

We also initialize Plugins and Helpers as two namespaces under our MyNameSpace variable, which we can use to hold special functions inside of our namespace for clarity and organization.

Plugin Parameters[54 – 59]

Starting on line 54, we register the plugin for use; this means we can actually see it in the editor when we look up the plugin name. The string has to match the filename of the plugin.

New Plugin[61]

On this line, we create a new function, which acts as a place for our new plugin under our Plugins namespace. This is just to organize our plugins in the game when it’s running.

Use Strict[64]

‘use strict’ is to promote better error checking in our code, and make it easier to maintain. This will help us improve our code quality.

Public API [75-79]

This is where you put any sort of functionality you want to export to the user as methods, or anything else you want to put here. In the example, we have two helper methods, that we can use inside of the game as script calls. The “$” represents our namespace, which is based on what we pass in on line 87.

Run The Code[86]

This line we simply run our newly created function; the game will then have all the work we have prepared once the game starts.

 

Conclusion

Hopefully, this helps you and if it does, share it with your friends, or anyone else you think it might help!

Leave a Reply

Your email address will not be published.