MZ VisuStella Variable Gauges - Setting Max Value with JS

I'm using VisuStella Variable Gauges plugin. Basically you choose a game variable and this plugins fills and depletes the gauge dynamically when that variable is updated. Sweet!

However, when creating a gauge, you need to assign its MAX VALUE manually, which by default is set to a number, 100 :

Capture d’écran, le 2022-03-25 à 23.32.27.png


The documentation says I can use JS to set that value instead, but I can't get it to work. Guess I should be using the "Insert calculations here" section... but the best I can think of is simply this :

Capture d’écran, le 2022-03-25 à 23.31.57.png


I'm getting an error message at launch saying the value is "not finite", even if my game variable (in this example #256) is definitely set to a number.

Basically I'm trying to create a HP gauge for my Actor with current HP value as the gauge plugin variable, and use variable 256 as the current HP Max of my Actor to set the gauge's MAX VALUE with JS.
How will you update the current HP variable?

I'm using VisuStella Variable Gauges plugin. Basically you choose a game variable and this plugins fills and depletes the gauge dynamically when that variable is updated. Sweet!

However, when creating a gauge, you need to assign its MAX VALUE manually, which by default is set to a number, 100 :

View attachment 221023

The documentation says I can use JS to set that value instead, but I can't get it to work. Guess I should be using the "Insert calculations here" section... but the best I can think of is simply this :

View attachment 221024

I'm getting an error message at launch saying the value is "not finite", even if my game variable (in this example #256) is definitely set to a number.

Basically I'm trying to create a HP gauge for my Actor with current HP value as the gauge plugin variable, and use variable 256 as the current HP Max of my Actor to set the gauge's MAX VALUE with JS.
The problem is that variable 256 starts with a value of 0, and that will initially be used as the value for max before your events have a chance to set it to a higher value, so the gauge is initially trying to set itself with a max of 0, which won't work.
How will you update the current HP variable?

That variable updates automatically whenever the value changes, no problem there. I can even refresh the gauge manually with plugin command, but there's no need really.

The problem is that variable 256 starts with a value of 0, and that will initially be used as the value for max before your events have a chance to set it to a higher value, so the gauge is initially trying to set itself with a max of 0, which won't work.

That makes sense. I'm using a common event at launch, with VisuStella Core > New Game Common Event, but I guess even that isn't "fast" enough to initialize the variable.

Any idea how to get around this ?
That variable updates automatically whenever the value changes, no problem there. I can even refresh the gauge manually with plugin command, but there's no need really.



That makes sense. I'm using a common event at launch, with VisuStella Core > New Game Common Event, but I guess even that isn't "fast" enough to initialize the variable.

Any idea how to get around this ?
Try setting the value of the variable to its initial value in the line above the one that sets max to it.
Try setting the value of the variable to its initial value in the line above the one that sets max to it.

That did it ! Looks like this, for anyone interested :


Capture d’écran, le 2022-03-30 à 19.06.52.png


Can't believe I didn't think of that. Thanks, cheers.

Original thread: https://forums.rpgmakerweb.com/threads/visustella-variable-gauges-setting-max-value-with-js.146128/