MZ [SOLVED]Are there any ways to get local variables value from individual enemies into the text of a Visustella MZ State Tooltip?

the title might be a bit misleading but i couldnt find a way to phrase it better with a pretty broad problem like that


So essentially im using visustella mz with their tooltips plug in

I have set up a stackable damage overtime state through JS code in notetags that declares a local variable on the target of the state and adds to the variable each time the state is applied, this variable is then used for the slip damage formula

the variable value is also reduced by one every turn and the state is removed from the target if the stack is <1 but this part is not really relevant

here is the code for it as it might be important for understanding the issue im having

Code:
<JS On Add State>

target.BurnStack ??= 0;

target.BurnStack += $gameVariables.value(2);

$gameVariables.setValue(1, target.BurnStack);

</JS On Add State>


<JS HP Slip Damage>


damage = Math.floor(b.BurnStack);


</JS HP Slip Damage>

<JS Post-Regenerate>

target.BurnStack --;

$gameVariables.setValue(1, target.BurnStack);


if (target.BurnStack < 1) {

  target.removeState (455);

}

</JS Post-Regenerate>

<JS Slip Refresh>

So this is all great and works exactly the way i want it to however, i want to display the amount of stacks any given target with this state has through State Tooltips plug in from visustella like this:

1741395396894.png


here im just storing the local variable value into a game variable which im then pulling in the tooltip text through a textcode, its just a make shift solution that works only if there is 1 target affected by it and thats the problem

because the text of the tooltip is determained in the notetags of this single particular state and i need it to somehow display different unique information for different targets affected with this same state

i didnt find a way for it to display local variables directly so i went and set up my own textcode \BurnStacks in visustella MessageCore plug in that would use JS code to determain the value that is displayed when this textcode is called
im not very experienced with JS so heres where i kinda ran into a dead end

What kind of JS code can i use to get the value from local variables on each enemy into the text of a tooltip so that when you hover over diffent enemies it would display their individual amount of burn stacks?

it makes sense to me to potentially through troop event, set up an array dedicated to burn stacks into which the state would be able to store the local variable value from each enemy which the could be accessed by the script of the textcode

but i kinda have no clue how to tell it to pull a particular index depending on the target you are HOVERING over

im prepared for there to just not be a real solution to this, and am completely open to it if you have ideas on how to achieve this type of effect through different means

this is a pretty big post, so even if you dont have much help to offer, thanks a lot for taking the time to read it
Hey,

The easiest option would probably be to use the "State Display" feature from the Skills&States Core plugin:

State Displays​


State Displays

To put values onto states and display them separately from the state turns you can use the following script calls.

battler.getStateDisplay(stateId)
- This returns whatever value is stored for the specified battler under
that specific state value.
- If there is no value to be returned it will return an empty string.

battler.setStateDisplay(stateId, value)
- This sets the display for the battler's specific state to whatever you
declared as the value.
- The value is best used as a number or a string.

battler.clearStateDisplay(stateId)
- This clears the display for the battler's specific state.
- In short, this sets the stored display value to an empty string.


You can then use $1 in your description to insert the state display into your tooltip.

There may be other options, I have not looked deep into the plugin documentations.
Hey,

The easiest option would probably be to use the "State Display" feature from the Skills&States Core plugin:



You can then use $1 in your description to insert the state display into your tooltip.

There may be other options, I have not looked deep into the plugin documentations.
hmmm doesnt seem to work unless im not using it properly

i tried putting it inside the description itself but since its text, it doesnt really work

and if i put it in the script of the custom textcode it cant define the battler
1741408214984.png

1741408234150.png


Thanks for the suggestion though, i'll try skimming the plugin documentations a couple more times in case i missed something after all
Ah, woops. I have not tried the script commands myself, but from my understanding they should work like this:
JavaScript:
<JS On Add State>
  target.BurnStack ??= 0;
  target.BurnStack += $gameVariables.value(2);
 
  target.setStateDisplay(455, target.BurnStack);
</JS On Add State>

<JS Post-Regenerate>
  target.BurnStack --;
 
  target.setStateDisplay(455, target.BurnStack);
 
  if (target.BurnStack < 1) {
    target.removeState (455);
  }
</JS Post-Regenerate>

<Help Description>
Abating damage over time ($1 tick(s) remaining)
</Help Description>
Replace 127 with the database ID of your state.
One consequence would be that the tick number would now also show up on the state itself.

Edit: Missed that your code already included the state ID.
Ah, woops. I have not tried the script commands myself, but from my understanding they should work like this:
JavaScript:
<JS On Add State>
  target.BurnStack ??= 0;
  target.BurnStack += $gameVariables.value(2);
 
  target.setStateDisplay(455, target.BurnStack);
</JS On Add State>

<JS Post-Regenerate>
  target.BurnStack --;
 
  target.setStateDisplay(455, target.BurnStack);
 
  if (target.BurnStack < 1) {
    target.removeState (455);
  }
</JS Post-Regenerate>

<Help Description>
Abating damage over time ($1 tick(s) remaining)
</Help Description>
Replace 127 with the database ID of your state.
One consequence would be that the tick number would now also show up on the state itself.

Edit: Missed that your code already included the state ID.

nah still just shows the dollar sign like its text, as i said i think both the engine and message core just dont recognize script calls within a text box space unless its one of the predefined textcodes , which i tried putting the command inside of too but THAT in turn will just result in battler or target being undefined because if the script is in there it doesnt seem to have access to the battle proccessing stuff maybe?

(screenshot 2 is what i mean when i say js code inside a textcode, since you can make your own through textcode replacement in the message core plugin parameters from what i understand, which is how i was trying to get around the tooltip being governed by textbox rules)

something i also thought of is maybe setting up unit ids within each individual troop through events and then accessing that instead through js textcode but again im not really sure what kind of logic would get us there
1741414656020.png


1741414724765.png
- Insert %1 into the help description to show any data that would otherwise
be shown as the state display, such as Absorption Barrier count.
I guess that is the result of not testing anything... Try to replace the $1 with %1.
I guess that is the result of not testing anything... Try to replace the $1 with %1. :]
OH MY GOD WAS THAT IT

1741415893697.png


wow that turned out to be so simple

THANK YOU SO MUCH

Original thread: https://forums.rpgmakerweb.com/threads/solved-are-there-any-ways-to-get-local-variables-value-from-individual-enemies-into-the-text-of-a-visustella-mz-state-tooltip.176077/