What you may need to know about MV as a scripter.

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
Hello, I started to note, a common list of things than people are having when they import your plugin inside their game,

many of you may already have actually had to battle with this probles without knowing why it doesn't work.

Here I'll compile an entire list of those so common bugs, and how to avoid them, or to check:

When testing the game, remember to press F8 to open the console, that is actually the only and best way you have to debug it properly on your MV editor.

Parameters doesn't work, my plugin breaks with no reason or says things like undefined "MyPluginName"

This problem happens when the user renames your script as another name, so they plugin manager can't load the parameters properly.

  • As a recommendation, name your plugins like a javascript identifier: /[A-Za-z_][A-Za-z0-9_]*\.js/Why?
People actually are doing that, so it's just to keep consistency

  • Add a little snippet if your plugin uses parameters:
if(!Object.keys(PluginManager.parameters('MyScriptName')).length) {    throw new Error("It seems than you named 'MyPluginName' differently, this plugin won't work that way!");}You cal also use this function:

function isEmpty (obj) { for (var k in obj) if (obj.hasOwnProperty(k)) return false; return true;}
  • Why?
This will prevent your plugin for crashing the game, so it's quite usefull and people will know why it doesn't work!

My plugin requires another, how do I manage that?

The Imported variable was added only for that idea:

if (!Imported["MyDependency"]) { throw new Error("The plugin 'MyPluginNames' requires 'MyDependency' plugin to work!");}That's why it's usefull.

If you are using MVCommons, you can also check using:

PluginManager.imported(string key)Even when both do the same, this one may be more easy to understand sometimes.

Note:

As I found more common bugs, I'll post here how to give a better information to users about them, so we can (hopefully) reduce the amount of bug reports that way.
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
if (!PluginManager.parameters('MyScriptName')) {    throw new Error("It seems than you named 'MyPluginName' differently, this plugin won't work that way!");}
This won't work. PluginManager.parameters() falls back to returning an empty object if it can't find the plugin. Empty objects aren't considered falsy and thus your error will never get thrown. What you could do is:

if(!PluginManager.parameters('MyScriptName').keys.length == 0) {...}This might break your game in IE8 or lower, though, so you might fallback to a different method:
Code:
var isEmpty = function(object) {    for(var a in object) {        return false;    }    return true;}; if(isEmpty(PluginManager.parameters('MyScriptName'))) {...}
A better solution (in my opinion) is using a different method for retrieving plugin parameter, like this small (and currently untested, so beware) snippet, which allows to define a plugin id in @plugindesc: http://pastebin.com/zSCKKBsE/edit: If modified, that script could actually render the whole Imported variable unneeded and register plugins by their plugin id. I wouldn't do this (at least not in the same script), since my Addon wasn't meant to be used as a needed dependency.
 
Last edited by a moderator:

Ramiro

Now with an army of Mecha-Ralphs!
Veteran
Joined
Aug 5, 2015
Messages
858
Reaction score
364
First Language
Spanish
This won't work. PluginManager.parameters() falls back to returning an empty object if it can't find the plugin. Empty objects aren't considered falsy and thus your error will never get thrown. What you could do is:

if(!PluginManager.parameters('MyScriptName').keys.length == 0) {...}This might break your game in IE8 or lower...
This doesn't, and it has IE9+ support:

if(!Object.keys(PluginManager.parameters('MyScriptName')).length) { ... }My bad.. but anyway.. fixed... thanks for the bugfix
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
One of the things you need to know is how to trace logic through undocumented core scripts. This allows you to then figure out how things are implemented
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
It's generally good practice to take a look at VX Ace when trying to understand how certain things work in MV. The implementation is sometimes different, but they kept the general structure of the engine and most of the names are still the same.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD

Forum statistics

Threads
105,868
Messages
1,017,074
Members
137,578
Latest member
JamesLightning
Top