public

Rpg Maker Developers Group

Simple enough for a child, powerful enough for a developer

2 Followers

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

BMM Archive · July 15, 2026

Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.

Original Source

  • Original title: MZ (VisuStella) Pass game variable instead of number in Skills and States Core?
  • Original author: venajiro
  • Original date: May 5, 2024
  • Source thread: https://forums.rpgmakerweb.com/threads/visustella-pass-game-variable-instead-of-number-in-skills-and-states-core.168372/
  • Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Javascript/Plugin Support

Summary

I'd like to be able to pass a game variable into the States and Skills Core notetags instead of a number value. (EG: instead of ). 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...

Archived First Post

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));

Downloads / Referenced Files

Log in to download

Log in, then follow the RPG Maker Developers Group to see these download links.

Log in to download
Creator Claims / Removal

If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.

#039#rpg-maker-archive#js-support

Replies (0)

No replies yet.

0 replies 1 view

Log in to reply.

User Avatar