Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
First Language
English
Primarily Uses
RMMZ
Drak Plugin Core v1.01
Drakkonis

Introduction
This plugin was developed to aid plugin creation, as I found myself having to rewrite the same general functions in nearly each plugin I made. So I stuck them all in here. As such, my more "robust" plugins will all require this plugin. Coincidentally, it can be used as a standalone tool to aid in the creation of your own plugins.

Features
There are currently 3 primary functions for this core plugin.
Function 1 - Color Conversion
Function 2 - Getting Notetag Block Data
Function 3 - Plugin Parameter Conversion

How to Use
Just save the script to a file called "Drak_Core.js". If you use any of my plugins that require this plugin (none released at this time), just put this plugin above them in the plugin list. If you're using it to develop your own plugins, make sure this is above those plugins as well.

Plugin Commands / Script Calls
Function 1 - Color Conversion
Calling ColorManager.getColor(color) is used to accomodate having a single parameter for a color setting and not needing to restrict it to system or hex colors. Pass either to this function, and the output is hex.

Function 2 - Getting Notetag Block Data
DataManager.assignNoteBlockData takes a $data object, such as $dataActors, and as many notetag keywords as you like, and runs through each object in the data, pulling every line between <note key> and </note key> lines, and sticking that data on the object in question for easy data access. The data is stored as an array directly on the $data object, with the name equal to the keyword. If there are spaces in that keyword, you'll need to either rename/manually reassign the array later, or simply use $dataObject["note key"] format to access the data.

Function 3 - Plugin Parameter Conversion
One of the first things a plugin with parameters does is pull all the parameters from PluginManager, and usually convert them for easy use. PluginManager.convertParams(pluginName) will automatically convert all parameters associated with that plugin, including automatically parsing any JSON-escaped objects and strings(even nested JSON objects!). It returns the entire collection as a single object, so instead of assigning a variable to PluginManager.parameters(pluginName), assign it to PluginManager.convertParams(pluginName) instead.

A note for function 3: It automatically assumes what the data is supposed to be, since parameter values are all initially strings. This means that, for example, if you want a value with a number to be a string type instead of a number type, this function will actually provide extra work by requiring you to manually convert it back to a string. The assumptions are made by the content of the string, with no way to specify any exceptions. Also, any blank values are set to null. If you don't want that to happen at all, feel free to delete the line in question (line 90).

Download
Drak Plugin Core

Terms and Credits
Free for use in any project, commercial or otherwise. Credit Drakkonis.

Miscellaneous
I'll most likely be adding features to this plugin as I find myself writing other functions over and over again. I'm also open to adding other features for plugin developing ease, these are just what I figured some of the most common "necessities" for plugin development were. I'm certainly open to suggestions!

For anyone using this plugin to make your own, I recommend learning how to do some of this stuff yourself, if you don't already know how. Yes, this plugin automates a lot of the heavy lifting, but I feel it is important to develop your own style as a programmer, as well as learning how to do what you need done. If you're learning how to deal with nested JSON parameters, for example, this plugin will make sure your plugin works(on that aspect, anyway), but I HIGHLY recommend learning to do it WITHOUT this plugin, just so you know how to do it, if nothing else. That's not to say I don't want you to use this plugin, I wouldn't release it otherwise. I just feel that there's something special about knowing how to do it on your own, that it makes you a better programmer in the end. On the other hand, you really can't beat efficient automation of an annoying task(and nested JSON parameters, for me, was a MAJOR PITA to figure out, as well as work with. It was a major inspiration for developing the 3rd function).
 
Last edited:

ephesus

Veteran
Veteran
Joined
Dec 10, 2015
Messages
77
Reaction score
47
Primarily Uses
If none of this makes sense to me but I want it to where is a good place to start? ...I don't know JS even. ;)
 

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
First Language
English
Primarily Uses
RMMZ
If none of this makes sense to me but I want it to where is a good place to start? ...I don't know JS even. ;)
There's really only two uses for this plugin. Some of my plugins will require it, so you'll need this to get them to work, but simply installing it correctly is all that's required. Currently, not many of my plugins require this one (I think only 1 or 2 right now, but there are more in the pipeline). The other use is for a plugin developer to make use of the functions this plugin contains. If you don't know JS then the second use won't be of much use. Pun possibly intended. lol

As for learning JS... that's entirely dependent on how much programming you already know. If you're familiar with programming concepts, JS is somewhat easy to follow most of the time. If you're familiar with any programming languages similar to C, it's even easier to follow, I've noticed a lot of similar structure, at least with C++(I don't know C++, just watched some YouTube videos with a guy who codes in it and noticed a lot of similarities in the basic format). In those cases, google searches for stuff might be sufficient, at least it was for me.

If you don't know programming at all, but want to learn JS anyway.... there are some basic courses and such here and there that can help get you started. Saw an intro on YouTube by freeCodeCamp.org on the topic that seems to be both basic and informative.

Just don't write code in a simple text editor. You CAN... but there are free programs out there that are FAR more useful when coding.
 

ephesus

Veteran
Veteran
Joined
Dec 10, 2015
Messages
77
Reaction score
47
Primarily Uses
Is Notepad++ good enough?

Sry, not trying to derail.

Function 1, Color conversion, if I'm not bugging you too much could you go a little more into that one, sounds interesting, couldn't quite grasp. Color use and theory and anything close to do with it is awesome stuff imo.
 
Last edited:

Drakkonis

Veteran
Veteran
Joined
Mar 5, 2021
Messages
210
Reaction score
160
First Language
English
Primarily Uses
RMMZ
Is Notepad++ good enough?

Sry, not trying to derail.

Function 1, Color conversion, if I'm not bugging you too much could you go a little more into that one, sounds interesting, couldn't quite grasp. Color use and theory and anything close to do with it is awesome stuff imo.
Whatever works best for your purposes will always be good enough. I don't personally use Notepad++, but I know some do use it for their coding. I personally use Visual Studio Code, but that's also because I learned Visual Basic when I started coding, so the Visual Studio interface is what I'm used to.

For the color function, it simply has to do with how MZ gets color data. Normally, you grab a color using its index on the color palette of your window skin and MZ gets the hex code for that color off of that. But some plugin developers want to either allow or force other color options, especially seeing as, by default, the window skin only allows 32 colors. And the user may decide on a different window skin with a completely different color palette from the default.

In the case of developing a plugin that allows the user to choose colors for something, you normally would need to either pick a format for the parameter (color index, hex code, or rgba layout), or make a parameter for all three... for EACH option you want to allow color selection for. That can get unwieldy FAST, especially if you don't force a preference hierarchy in the code in the event of a user filling out more than one of the formats for a given option.

My color function allows you to not have to choose between color index and hex code for color selections, you can have a single parameter for each color option, let the user put in whatever they want, and the function does the rest. If the parameter is ALREADY hex code, it simply returns that code and doesn't do anything else. But if it's an integer between 0 and 31, it's a palette index, so the function grabs that color from the palette and returns THAT hex code. It's good for making sure the color data format is what you expect it to be regardless of what the user chooses. They can use a palette index if they want, or they can get the hex code for the exact color they want.

I've seen a few plugins prefer rgba color format, so I might look into adding that into the function, or at least adding another function for that, just to cover all the bases.
 

Latest Threads

Latest Posts

Latest Profile Posts

today is my birthday
Don't you just hate it when you get a high level armor only for it to look like a metal plated bikini on your female character?? Seriously. How can that protect you??? Enemies can hit the squishy parts! :kaosigh:
Bathrooms are not designed for the middle of the night.
so... I decided since a park was an area in my game... here's an enemy that's slide with a hand behind it. cause why not.

Forum statistics

Threads
115,277
Messages
1,088,556
Members
149,886
Latest member
Br8228
Top