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 ;)
Question about JS, Parameters and Plugin Command
● ARCHIVED · READ-ONLY
-
-
//===========================================================================//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:Ok, things are shaping up swimmingly except for one lingering issue. How can I make plugin in commands in different javascript files?
//===========================================================================//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]); }};
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. -
Do you have your plugin wrapped in an anonymous function?
Code:Because this is exactly what happens, when you declare public variables and accidently overwrite existing ones.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! }; })(); -
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).