Question about JS, Parameters and Plugin Command

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
423
Reaction score
170
First Language
Dutch
Primarily Uses
RMMV
Do with it whatever you want, no credit nothing required.

Would appreciate it though if you would rename the Silv variable to your own to avoid conflicts ;)
 
Last edited by a moderator:

shrap_x

Villager
Member
Joined
Oct 26, 2015
Messages
20
Reaction score
0
First Language
English
Primarily Uses
//===========================================================================//Game_Interpreter Plugin Commands//===========================================================================var shrap_x_interpreter = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function (command, args) { shrap_x_interpreter.apply(this); if (command === 'EnableMapDebug') { $gameSystem.EnableMapDebug(args[0]); }};
Code:
//===========================================================================//Game_Interpreter Plugin Commands//===========================================================================var shrap_x_interpreter = Game_Interpreter.prototype.pluginCommand;Game_Interpreter.prototype.pluginCommand = function (command, args){    shrap_x_interpreter.apply(this);    if (command === 'EnableFollowerStopLeaderDir') {        $gameSystem.EnableFollowerStopLeaderDir(args[0]);    }};
Ok, things are shaping up swimmingly except for one lingering issue. How can I make plugin in commands in different javascript files?

So they are appended to each other. Right now I am exceeding the stack size due to duplicates.

I figured this was wrong up front but tried it anyway.

Do I need to modify this with the alias?

Sorry for asking so many questions.
 
Last edited by a moderator:

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
859
First Language
German
Primarily Uses
Do you have your plugin wrapped in an anonymous function?

Code:
var MODULE = MODULE || {};    // Your public namespace(function() {    "use strict";                                  // Your entire plugin.         MODULE.PLUGIN = {                              // Your public API. "PLUGIN" needs to be different for each plugin!    };    })();
Because this is exactly what happens, when you declare public variables and accidently overwrite existing ones.
 

SilverDash

Veteran
Veteran
Joined
Oct 11, 2015
Messages
423
Reaction score
170
First Language
Dutch
Primarily Uses
RMMV
It seems he hints that he doesn't know how to alias and that he is just trying something. So even with anonymous functions he would cause it to crash sooner or later.

If he would have used my template it wouldn't be possible to have a duplicate alias though ;) . No need for an anonymous function. But IF you skip on the anonymous function, you better know exactly what you are doing or things turn ugly. So I would also recommend him using an anonymous function (for now).

I highly recommend any starting plugin writers to use the anonymous function around all of your code at first. When you get more experienced, drop it later on.

Also there is a bug in his code:

shrap_x_interpreter.apply(this);should be:

shrap_x_interpreter.apply(this, arguments);The other possible problem is that if he did not use an anonymous function, he indeed now declared an (probably accidental) public variable called shrap_x_interpreter which also clutters the global window namespace. On top of that it doesn't sound very unique so if he would create another plugin, it would probably conflict already. Each alias must be unique (per scope).
 

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

Latest Threads

Latest Posts

Latest Profile Posts

BCj
Ew, why does my blogpost on the rpgmaker.net site look like a garbled mess? Are html codes disabled or something?
I feel that I should cut down on my order queue so I can get some more time for my projects, its been quite a longggg while since I worked on them LOL
I friend of mine insisted on practicing dubbing things with him... and its quite funny, yet, it really takes a huge amount of practice!
Gotta save this for my next thread later...
Finsh all of the walking dead game in a week, such an amazing emotional trip

Forum statistics

Threads
97,877
Messages
947,572
Members
129,111
Latest member
mariominestrone
Top