Created
November 3, 2016 03:49
-
-
Save KinoAR/097e8b46a65a6fd1e748f675c69d05b1 to your computer and use it in GitHub Desktop.
A plugin pattern for creating plugins in RPGMaker MV
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================================================================= | |
// PluginPattern.js | |
//============================================================================= | |
/*: | |
* | |
* @author Plugin Author Name | |
* @plugindesc The description of my plugin. | |
* | |
* @param Example Param 1 | |
* @desc A descrtion for a parameter for my plugin. | |
* @default 400 | |
* | |
* @param Example Param 2 | |
* @desc A description of my second param which is a string | |
* @default Example Test | |
* | |
* @help | |
* This is where you put the help information for your plugin. | |
* | |
//============================================================================= | |
// Contact Information | |
//============================================================================= | |
* | |
* Contact me via twitter: EISKino, or on the rpg maker forums. | |
* Username on forums: Kino. | |
* | |
* Forum Link: http://forums.rpgmakerweb.com/index.php?/profile/75879-kino/ | |
* Website Link: http://endlessillusoft.com/ | |
* Twitter Link: https://twitter.com/EISKino | |
* Patreon Link: https://www.patreon.com/EISKino | |
* | |
* Hope this plugin pattern helps, and enjoy! | |
* --Kino | |
*/ | |
//Namespace for any code you create; replace this with your own name | |
const MyNameSpace = MyNameSpace || {}; | |
//Create a new namespace for plugins | |
MyNameSpace.Plugins = MyNameSpace.Plugins || {}; | |
//Helpers for Utility Functions or for developer uses | |
MyNameSpace.Helpers = MyNameSpace.Helpers || {}; | |
(function($) { | |
//============================================================================= | |
// PluginManager Parameters | |
//============================================================================= | |
//Registers the Plugin for use | |
var parameters = PluginManager.parameters("PluginPattern"); | |
//A place that holds all the parameters from your plugin params above | |
const PluginPatternParams = { | |
ExampleParam1: Number(parameters['Example Param 1']), | |
ExampleParam2: String(parameters['Example Param 2']) | |
}; | |
$.Plugins.Plugin1 = function($) { | |
//This use strict keyword helps you write better code | |
//it catches more possible errors in the code. | |
'use strict'; | |
//This is where you write your own code. | |
//Write whatever you want for your plugins. | |
//============================================================================= | |
// Public API / Exports | |
//============================================================================= | |
//These are functions that you can access through your namespace | |
//Example Access: MyNameSpace.Helpers.helper1("Hello World"); //Prints "Hello World" to the console | |
$.Helpers.helper1 = function(Text) { | |
console.log(text); | |
}; | |
$.Helpers.helper2 = function() { | |
console.log(PluginPatternParams.ExampleParam2); //Example Test | |
}; | |
}; | |
//Run All Plugin Code | |
$.Plugins.Plugin1(); | |
})(MyNameSpace); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment