[Solved]Plugin Command

I am using the plugin TMCard and there's the plugin command startCardBattle name val1 val2,val3,val4.
Then i checked the section of the plugin for the game interpreter
JavaScript:
var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
    Game_Interpreter.prototype.pluginCommand = function(command, args) {
        _Game_Interpreter_pluginCommand.call(this, command, args);
        if (command === 'startCardBattle') {
            var arr = args.map(this.convertEscapeCharactersTM, this);
            var enemyName = arr[0];
            var enemyItemCardId = +arr[1];
            var enemyCardIds = arr[2].split(',').map(Number);        
            $gameParty.setActiveDeck(-1);
            SceneManager.push(Scene_CardBattle);
            SceneManager.prepareNextScene(enemyName, enemyItemCardId, enemyCardIds);
}
I want val1 val2 val3 val4 to be random numbers.. so i tried using a script call with this:
JavaScript:
$gameParty.setActiveDeck(-1);
SceneManager.push(Scene_CardBattle);
SceneManager.prepareNextScene("Enemy", 20, [1,2,3]);
I automatically get the error "Reference Error : Scene_CardBattle not defined". What is causing the error?

Edit:
Solution found for TMCard Random Card Battle
1589248270854.png
from a quick check you give an array of numbers, but the function still expects an array of strings. There is no conversion yet in the original function, the original value string was only split and then modified.
Scene_CardBattle not defined seems to indicate that part of the script is missing. It could be that the way the plugin is written, the classes are not available to be called outside of it.

Rather than trying to call the plugin itself directly via script, you might have better success calling Game_Interpreter's pluginCommand via script:

Code:
Script: this.pluginCommand('startCardBattle', [20, 1, 2, 3]);

I've moved this thread to Javascript/Plugin Support. Thank you.

I get a reference error with that script call.. I need the val1 val2 val3 val4 to be random numbers..
the example for the script call is startCardBattle enemy 0 1,2,3.

I was thinking i need to get what the args are. then ill have them assembled into a single string to be the args that will be processed.
What reference error?

Please provide a link to the script.
Link to the script is in my signature or here. I tried the script call you gave me.. i get a syntax error
i get a syntax error
such statements of errors do not help much. what we need to help is the complete error message, preferably as a screenshot, exactly because people who do not know how to read error messages often omit important details when telling about it.
@Shaz gave the code :
JavaScript:
this.pluginCommand('startCardBattle', [20, 1, 2, 3]);
it gave me this:
Code:
TypeError
undefined is not a function
Here's the console screenshot
1589197554005.png

so i tried :
JavaScript:
this.pluginCommand('startCardBattle', ['Enemy 20 1, 2, 3"]);
I get the error:
Code:
TypeError
Cannot read property 'split' of undefined
As @Shaz said before you're providing it with an array, not four strings as it's expecting.

The normal plugin command converts everything in the text box into one long string, and then the individual command choose what to do with it.

this.pluginCommand('startCardBattle 20, 1, 2, 3');

Format your script call as if it were being called via the plugin command option, otherwise the plugin has no idea how to interpret the data you're giving it.

Assuming you don't get an error from that script above, you can then define some variables and use them as values for the call:

JavaScript:
var arg1 = Math.randomInt(10)+1
var arg2 = Math.randomInt(10)+1
var arg3 = Math.randomInt(10)+1
this.pluginCommand('startCardBattle 20, ' + arg1 + ', ' + arg2 + ', ' + arg3);
@ramza it doesn't work..
JavaScript:
var arg1 = Math.randomInt(10)+1;
var arg2 = Math.randomInt(10)+1;
var arg3 = Math.randomInt(10)+1;
this.pluginCommand('startCardBattle', 'Enemy 0 ' + arg1 + ',' + arg2 + ',' + arg3);
there are 3 things the input needed:
JavaScript:
enemyName = arr[0]   -> "enemy"
enemyItemCardID = arr[1]  -> "20"
enemyCardIDs = arr[2]  -> "1,2,3"

I tried the simplest way of that string thing and it's the same error Type Error
JavaScript:
this.pluginCommand('startCardBattle', 'Enemy 20 1,2,3');
@ramza it doesn't work..
JavaScript:
var arg1 = Math.randomInt(10)+1;
var arg2 = Math.randomInt(10)+1;
var arg3 = Math.randomInt(10)+1;
this.pluginCommand('startCardBattle', 'Enemy 0 ' + arg1 + ',' + arg2 + ',' + arg3);
there are 3 things the input needed:
JavaScript:
enemyName = arr[0]   -> "enemy"
enemyItemCardID = arr[1]  -> "20"
enemyCardIDs = arr[2]  -> "1,2,3"

I tried the simplest way of that string thing and it's the same error Type Error
JavaScript:
this.pluginCommand('startCardBattle', 'Enemy 20 1,2,3');
Now you're giving it two strings. the plugin help text states the command is startCardBattle 村人A 0 1,2,3. There is no comma between the plugin command and the arguments, therefore your script call for that plugin command should also not be separate strings.
I tried those 1 string or 2 string. they all give the same error.
I even tried it with the plugin YEP_ScriptCallPluginCmd.js, and it just skips the card battle scene.

EDIT:
Please close this. the pluginTM already has it built inside it to use Escape characters with the function
convertEscapeCharactersTM. You can use game variables and actor names already with the plugin command startCardBattle \v[1] \v[2] \v[3],\v[4],\v[5]. I'm using startDeckSelect cause for some reason the startCardBattle broke.
Here's a screenshot
1589248176245.png
Just report your first post and let the mods know you found the solution, then they'll close it. Don't rely on them seeing 3 small words within a post within a long thread.

Also, glad you found a solution. Plugin instructions is always a good place to look first 🙂 (assuming they were there)

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/solved-plugin-command.121380/