MZ (SOLVED) Making my own scriptcall to enable using a variable in a plugin command (VisuStella Party System)

**Thankfully this request doesn't require familiarity or purchase of VS Party System, just a little knowledge of javascript.

Problem: I need to lock 2 party members so the player cannot remove/switch them in the party formation window.
Visu provides a plugin command that lets you lock ONLY by Actor id.
But, I need to lock by which position in the party order they are (1st, 2nd, etc)
Any actor at all could be there, so ONLY locking by Actor cannot work!
Plugin command:
Spoiler: Plugin Command
CustomScriptcallRequest1plugincommand.png


As a solution, I've seen some talented users like Another Fen and rpgLord69 create custom script calls just from looking at a 'outlines of the command in the header' from the Plugin file.

So I just need to make a small script call that does the same thing as a plugin command, except that it allows the use of a variable rather than a static number, basically.
The command outline of a plugin file is not obfuscated, unlike the rest of it that contains the actual code.

vHere is the required part of the Outline of the command header of VisuMZ_2_PartySystem
Spoiler: Commands
CustomScriptcallRequest2Commands.png

A year ago I was helped with something very similar to this once before at this post:

JavaScript:
//Another Fen's Code from that post
//

let name = "VisuMZ_1_BattleCore";
let command = "ActSeq_Mechanics_AnalyzeWeakness";
let targets = JSON.stringify( [`enemy index ${$gameVariables.value(299)}`] );
let reveal = "1";

PluginManager.callCommand(this, name, command, {
    "Targets:arraystr" : targets,
    "Reveal:eval" : reveal
});

So, using that information/solution provided as a template I tried creating my own scriptcall, and experimented with using it, along with several other variations...
But it always shows a 'Script Call Error' in the log, so clearly I haven't created it correctly. 😢
I feel like I'm half-way there, so does anyone see what's wrong with my cobbled-together custom scriptcode?

JavaScript:
let name = "VisuMZ_2_PartySystem";
let command = "LockPartyMembers";
let targets = JSON.stringify( [`${$gameVariables.value(1)}`] );

PluginManager.callCommand(this, name, command, {
    "Actors:arraynum" : targets,
    "Lock:boolean" : true
});

idk how I'm managing to mess this up, the only 2 arguments within the command are:
Actors:arraynum (which is like a list of numbers because it wants one or multple ActorIDs)
and
Lock:eval (which has a boolean, which is just true or false)

-Thank you for reading!
You wrote "Lock:boolean" when it should be "Lock:eval"

And I wouldn't use variable 1 for anything (actually I never use variables 1-10) since it's easy for some plugin to have reserved that for something. Unless you checked everything.
You wrote "Lock:boolean" when it should be "Lock:eval"

And I wouldn't use variable 1 for anything (actually I never use variables 1-10) since it's easy for some plugin to have reserved that for something. Unless you checked everything.
Thank you so much, that was exactly it!
I really was almost there!
The final correct custom scriptcall:

JavaScript:
let name = "VisuMZ_2_PartySystem";
let command = "LockPartyMembers";
let targets = JSON.stringify( [`${$gameVariables.value(1)}`] );

PluginManager.callCommand(this, name, command, {
    "Actors:arraynum" : targets,
    "Lock:eval" : true
});

Incidentally I also found that you can replace the variable with:
$gameParty.members()[0]._actorId
to lock the person in the 1st party slot, so that's also immensely helpful!
JavaScript:
let name = "VisuMZ_2_PartySystem";
let command = "LockPartyMembers";
let targets = JSON.stringify( [`${$gameParty.members()[0]._actorId}`] );

PluginManager.callCommand(this, name, command, {
    "Actors:arraynum" : targets,
    "Lock:eval" : true
});

And you are of course correct, var 1-10 I keep blank except for a small testing map where I can experiment with these things before changing to a more permanent variable.

Thank you again, rpgLord69
I really appreciate you taking the time to solve this! 😂
Not sure those are helpful in the future, since this one already works, but just in case:

JavaScript:
"Lock:eval" : true
Plugin Command parameters should generally be text strings. Usually this should work anyways since Javascript will convert values in a lot of cases, but if it ever doesn't, try using either "true" or JSON.stringify(true) instead.

JavaScript:
let targets = JSON.stringify( [`${$gameParty.members()[0]._actorId}`] );
I think I modeled the last suggestion to be close to the one you already got, but if you want to save some space, you could also write it like this:
let targets = `["${$gameParty.members()[0]._actorId}"]`;
Basically you could copy the text version of your parameter, put it in backticks, and replace the variable part with a ${code} block (and also put an extra backslash before any back tick, backslash and $ in your text so Javascript does not get confused when interpreting the text).

Alternatively, if you prefer, you can put text strings in either single- or double quotes (which would respectively need to be backslashed in your actual text). Those do not support code inserts though, but you could assemble them like this:
let targets = '["' + $gameParty.members()[0]._actorId + '"]';
let targets = "[\"" + $gameParty.members()[0]._actorId + "\"]";
I do love to learn new ways to be more efficient, thank you so much for the tips!!

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-making-my-own-scriptcall-to-enable-using-a-variable-in-a-plugin-command-visustella-party-system.181726/