MZ (VisuStella) Pass game variable instead of number in Skills and States Core?

I'd like to be able to pass a game variable into the States and Skills Core notetags instead of a number value. (EG: <Potion Cost: \V[x]> instead of <Potion Cost: x>). I had a look into the JS: Cost Calculation for the Skill Cost Types parameter and I can see that it's grabbing the value there, but I don't know enough JavaScript to be able to add an option there for it to read a game variable and pass it as a number value, or if I do manage to add it, if this value will update as the game variable is changed via events.
If anyone could suggest any JS changes I could make to the Cost Calculation, or to another area of the plugin parameters that I've overlooked, that would be very helpful. Thank you.

JS: Cost Calcuations in VisuStella: Skills and States Core (Created by the VisuStella team)
JavaScript:
// Declare Variables

const user = this;

const skill = arguments[0];

let cost = 0;



// Calculations

const note = skill.note;

if (note.match(/<POTION COST:[ ](\d+)>/i)) {

    cost += Number(RegExp.$1);

}

if (note.match(/<JS POTION COST>\s*([\s\S]*)\s*<\/JS POTION COST>/i)) {

    const code = String(RegExp.$1);

    eval(code);

}



// Apply Trait Cost Alterations

if (cost > 0) {

    const rateNote = /<POTION COST:[ ](\d+\.?\d*)([%%])>/i;

    const rates = user.traitObjects().map((obj) => (obj && obj.note.match(rateNote) ? Number(RegExp.$1) / 100 : 1));

    const flatNote = /<POTION COST:[ ]([\+\-]\d+)>/i;

    const flats = user.traitObjects().map((obj) => (obj && obj.note.match(flatNote) ? Number(RegExp.$1) : 0));

    cost = rates.reduce((r, rate) => r * rate, cost);

    cost = flats.reduce((r, flat) => r + flat, cost);

    cost = Math.max(1, cost);

}



// Set Cost Limits

if (note.match(/<POTION COST MAX:[ ](\d+)>/i)) {

    cost = Math.min(cost, Number(RegExp.$1));

}

if (note.match(/<POTION COST MIN:[ ](\d+)>/i)) {

    cost = Math.max(cost, Number(RegExp.$1));

}



// Return cost value

return Math.round(Math.max(0, cost));
Hmmm, I don't understand? Are you talking about the type cost notetags or something else? Because, like you said, there's already the JS type cost notetag. Just put there:
cost = $gameVariables.value(X)
Replace X with your variable number.
Hmmm, I don't understand? Are you talking about the type cost notetags or something else? Because, like you said, there's already the JS type cost notetag. Just put there:
cost = $gameVariables.value(X)
Replace X with your variable number.
Thank you for the reply. I'm looking to change the way the notetags themselves are read, so that I can insert any game variable into my notetags that replaces the usual number variable just so I can streamline the process a bit more. As for your solution, where should I declare my new cost value? Just at the end after the math function has complete?
I'm looking to change the way the notetags themselves are read
We can't. The VisuStella team obfuscates the code for their plugins, so they can't be read or edited by other people. Your only recourses are to use the JS Cost notetag rpgLord provided, or submit a petition to VisuStella to add the feature you're looking for.

I guess we could with that plugin parameter you posted. If you change
Code:
Number(RegExp.$1);
to
Code:
eval(RegExp.$1);

it would allow you to use JavaScript like $gameVariables.value() directly in that notetag.

But then it makes it harder to use regular numbers if you also do that anyplace, because you'd have to cast them into numbers instead of just typing them. It probably makes more sense to just use the JS notetag.

It's definitely an unnecessary amount of work to run the string through the escape code parser to make the \V[] syntax work.

As for your solution, where should I declare my new cost value? Just at the end after the math function has complete?
You put that inside of the notetag provided in the instructions.
Code:
<JS Potions Cost>
cost = $gameVariables.value(x);
</JS Potions Cost>
where x is the ID of the variable (no leading zeros).

You place that notetag in the Notes field of the skill.
We can't. The VisuStella team obfuscates the code for their plugins, so they can't be read or edited by other people. Your only recourses are to use the JS Cost notetag rpgLord provided, or submit a petition to VisuStella to add the feature you're looking for.

I guess we could with that plugin parameter you posted. If you change
Code:
Number(RegExp.$1);
to
Code:
eval(RegExp.$1);

it would allow you to use JavaScript like $gameVariables.value() directly in that notetag.

But then it makes it harder to use regular numbers if you also do that anyplace, because you'd have to cast them into numbers instead of just typing them. It probably makes more sense to just use the JS notetag.

It's definitely an unnecessary amount of work to run the string through the escape code parser to make the \V[] syntax work.


You put that inside of the notetag provided in the instructions.
Code:
<JS Potions Cost>
cost = $gameVariables.value(x);
</JS Potions Cost>
where x is the ID of the variable (no leading zeros).

You place that notetag in the Notes field of the skill.
Thank you very much! I'll take what you said about just using numbers into consideration, but for now this is a good solution to a specific system I was setting up.

Original thread: https://forums.rpgmakerweb.com/threads/visustella-pass-game-variable-instead-of-number-in-skills-and-states-core.168372/