Hi there people!
Well, I have a plugin with a lot of plugin commands.
It happens that some arguments are Number, boolean or strings(default ones).
I was converting each argument in each command the type that he has to be.
So I want to know a method to JSON.parse all the args because if I manage to do that, I will don't need to constantly convert them.
I have been trying some things, but I can't see in the console the results, to check how it's going.
Only thing I know that in-game they not work.
So I tried this:
My intention is, with this, now use in the code:
TIMER_START 10 TRUE OK
Command = TIMER_START.
10 = pArg[0] // number
true = pArg[1] // boolean
OK = pArg[2] // string
So the Mv will convert each argument to the proper type he is(Number, boolean...)
I know that each argument inserted is like a .push in an array of arguments.
But this array is always empty, right? They only get a fill after I type each argument in the plugin command. Right?
[EDIT]
This have worked:
Now I use pArgs0 in the code and work.
But maybe there is another way?
Well, I have a plugin with a lot of plugin commands.
It happens that some arguments are Number, boolean or strings(default ones).
I was converting each argument in each command the type that he has to be.
JavaScript:
Eli.SuperTimer.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
Eli.SuperTimer.Game_Interpreter_pluginCommand.call(this, command, args);
let commandUpper = command.toUpperCase();
let nArg0 = parseInt(args[0]); // number
let nArg1 = parseInt(args[1]); // number
let pArgs = JSON.parse(args[2]); // boolean
// code here...
}
I have been trying some things, but I can't see in the console the results, to check how it's going.
Only thing I know that in-game they not work.
So I tried this:
JavaScript:
Eli.SuperTimer.Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
Game_Interpreter.prototype.pluginCommand = function (command, args) {
Eli.SuperTimer.Game_Interpreter_pluginCommand.call(this, command, args);
let commandUpper = command.toUpperCase();
let pArgs = JSON.parse(args); // This will work?
// commands and code here...
TIMER_START 10 TRUE OK
Command = TIMER_START.
10 = pArg[0] // number
true = pArg[1] // boolean
OK = pArg[2] // string
So the Mv will convert each argument to the proper type he is(Number, boolean...)
I know that each argument inserted is like a .push in an array of arguments.
But this array is always empty, right? They only get a fill after I type each argument in the plugin command. Right?
[EDIT]
This have worked:
JavaScript:
for(let i = 5, l = args.length; l < i; i--){
args.push("0")
}
let pArgs0 = JSON.parse(args[0]);
let pArgs1 = JSON.parse(args[1]);
let pArgs2 = JSON.parse(args[2]);
let pArgs3 = JSON.parse(args[3]);
let pArgs4 = JSON.parse(args[4]);
But maybe there is another way?
[[EDIT 2]]
hahaha guess I'm too tired to code now xD
Can forget about this thread xD
Last edited:

