Scriptcall for State Name affecting actor(x)?

Hi there,

I was wondering if there is a call which can show the name of the state affecting actor(x) ?
It will help me display some HUD Battle informations,

I've already tried
${$gameActors.actor($gameVariables.value(x)).isStateAffected($gameVariables.value(y)).state.name()}
and
${$gameActors.actor($gameVariables.value(x)).State($gameVariables.value(y)).name()}
or
${$gameActors.actor($gameVariables.value(x)).stateName($gameVariables.value(y))}
even
${$states($gameVariables.value(5)).name}
then
${$dataStates($gameVariables.value(5)).name}
and I almost forgot
${$gameParty.States($gameVariables.value(5)).name}
But it does not work ...

Anyone ?

Thanks !
Determining what state is active can be tricky, but since I see you've thrown a game variable in there, let's assume you have the state number. In that case, try:

$gameActors.actor($gameParty.battleMembers()[$gameVariables.value(x)]._actorId)._states[$gameVariables.value(y)].name;

Where:
$gameVariables.value(x) = party member position
$gameVariables.value(y) = state number

And remember that battleMembers() uses 0 - 3, not 1 - 4, for the default four party members.
Hi,

First, thank you for you quick answer.

I do have a common event setting the $gameVariables.value(y) to a state number.
I tried yours but it doesn't work either.

Quick question : when do I use "[]" those instead of "()" those ?
battleMembers()[$gameVariables.value(x)]
And why have you put the game variable outside of the battleMembers "()" ?

It seems that it does not let the name of the state appears.
But thanks for trying. It is a tricky one I think ... may it would be easier to set my states as classes (because I'm doing an entire Battle Mode outside of the Battle Scene of RPG Maker, using HUD Maker switches possibilities and qPictures mouse control)
and use the classes name. What would be the class name script call in this case ?

Let's find out !

EDIT and SOLVED !

Alright, at first I wanted my state to determine what appears to be my class. I'm not using the RMMV Battle System, that's why I was little confused. Then, it was easy to set my HUD value because the javascript call to make the name of the class the actor has is :
${$gameActors.actor($gameVariables.value(x)).currentClass().name}
Where $gameVariables.value(x) is my actor class.

However, it seems this is kind of impossible to get the current state NAME of my actor, I've tried soooooo hard and it was so easy for his class. So if someone knows the magic formula, it will help a lot of people I think, because I've walk the entire RMMV topics and nothing about it !

Thanks a lot for your intervention @ZephyrAM , it was really helpful ! 🙂
Quick question : when do I use "[]" those instead of "()" those ?

And why have you put the game variable outside of the battleMembers "()" ?

() are used for functions and [] are used for arrays. I use both of them for battleMembers() because of what it returns - which I admittedly haven't delved into 'how' it does it, just that it does. Basically, the battleMembers() function returns the whole battle group, and using the [] lets you designate a single member. This is shown in the base engine function:

Game_Party.prototype.leader = function() {
return this.battleMembers()[0];
};

Also, as a last shot, if nothing else will return the state name, this will - harder to connect to the actor though:

$dataStates[$gameVariables.value(y)].name;

Edit:
As for how battleMembers() works - it returns a value using slice(), which outputs an array. Hence why [] works on the end ^_^
Code:
$dataStates[$gameActors.actor(actorId)._states[your-state-index]].name
should do the trick.

States are stored in the _states property of an actor object in the form of an array like this [stateId1,stateId2,...,stateIdn].
It just stores the state id, to get the actual name you have to find the actual state object stored in the $dataStates array and get its name property, which is what the above script call does.

Original thread: https://forums.rpgmakerweb.com/threads/scriptcall-for-state-name-affecting-actor-x.97592/