MV How to find which actor's turn it currently is

So i'm using SRD's Hud maker and was going to add a face graphic/animation that appears when it is a party member's turn to help with visual clarity.

So for the condition, i'm trying to find a statement i can put there so that the graphic only appears during that character's turn.
I looked around for a few threads and i found This thread.

But to be honest it was only kind of helpful, as i'm not sure what syntax to use at the beginning, since copy/pasting it from the thread hasn't seemed to work.

Still in the process of learning JavaScript so i'm not entirely sure when i need to add a !, $ or both.
The main problem with your idea is the question how the turn is defined in your battlesystem.

In the default turn-based battle system, there are two different times that could be defined as "actor turn": Actor input moment and actor action execution moment.
do you want the display to change on the actor input option? Or do you want it to change on the execution of the selected action?
Those are completely different times in the battleturn - and that assumes default turn based, other types of battle systems work completely different.

oh, and in javascript ! is a negation operator, that has nothing to do with the ! of sprite filenames.
Yeah, if you want it for the input phase, I think it's like (change X for actor's id):

BattleManager.actor().actorId() === X && BattleManager.actor().isInputting()
using "!" in JS is NOT euqal too, as for "$" is used as target.
mostly in $gameTemp, $gameSystem, $gameActor etc as
those are variables to draw infomation from it.

if you want to draw the current index in HUDmaker of which
actor's turn it is with 1 HUD

an condition like this can help: BattleManager.actor().actorId()
for seperately, use those:
Code:
$gameParty.members()[0] - 1st Member or Leader
$gameParty.members()[1] - 2nd Member
$gameParty.members()[2] - 3rd member
$gameParty.members()[3] - 4th Member
The main problem with your idea is the question how the turn is defined in your battlesystem.

In the default turn-based battle system, there are two different times that could be defined as "actor turn": Actor input moment and actor action execution moment.
do you want the display to change on the actor input option? Or do you want it to change on the execution of the selected action?
Those are completely different times in the battleturn - and that assumes default turn based, other types of battle systems work completely different.

oh, and in javascript ! is a negation operator, that has nothing to do with the ! of sprite filenames.
As i wrote my description, i Initially was looking for actor input moment, like when it's character 1's turn, his picture would appear, regardless of his order in the party.
Yeah, if you want it for the input phase, I think it's like (change X for actor's id):

BattleManager.actor().actorId() === X && BattleManager.actor().isInputting()
I tried adding this into the conditons for the hud element, and it said x was undefined, do i need to add brackets [] for x?
I tried adding this into the conditons for the hud element, and it said x was undefined, do i need to add brackets [] for x?
"change X for actor's ID"
"change X for actor's ID"
No sorry, i meant i tried that but it still said undefined.
No sorry, i meant i tried that but it still said undefined.
It literally can't say "x is undefined" unless you still have "x" in there.
But did they mean that it says that the BattleManager.actor() is undefined? Is it undefined at some times? Do you need to check first that it gives a battler?

Try like (change X):

if (BattleManager.actor() && BattleManager.actor().actorId() === X && BattleManager.actor().isInputting())
But did they mean that it says that the BattleManager.actor() is undefined? Is it undefined at some times? Do you need to check first that it gives a battler?

Try like (change X):

if (BattleManager.actor() && BattleManager.actor().actorId() === X && BattleManager.actor().isInputting())
I'm fairly certain MV supports null-chaining, and it's usually better to put the most restrictive condition first due to the left-to-right evaluation, so I would do

JavaScript:
if (BattleManager.actor?.().isInputting() && BattleManager.actor().actorId() === x)

The null-chain is only needed for the first one, because if that returns false, it stops checking.

Edit: Disregard, this will work in MZ but not MV. I would still switch the order of the conditions, though.
But did they mean that it says that the BattleManager.actor() is undefined? Is it undefined at some times? Do you need to check first that it gives a battler?

Try like (change X):

if (BattleManager.actor() && BattleManager.actor().actorId() === X && BattleManager.actor().isInputting())
Just tried that and i got an error message.
Condition: if (BattleManager.actor() && BattleManager.actor().actorId() === (2) && BattleManager.actor().isInputting())

and got this popup-
1750089040375.png


It's really weird, half of the time i input a condition statement, it doesn't save when i go back - i have to do it a few times to get it to save.
And other times if i try to edit a condition, it doesn't erase so i have to create a different element to get to that point.


I'm fairly certain MV supports null-chaining, and it's usually better to put the most restrictive condition first due to the left-to-right evaluation, so I would do

JavaScript:
if (BattleManager.actor?.().isInputting() && BattleManager.actor().actorId() === x)

The null-chain is only needed for the first one, because if that returns false, it stops checking.

Edit: Disregard, this will work in MZ but not MV. I would still switch the order of the conditions, though.
Kind of a similar thing happened with the first part of this reply:
1750090097929.png

Not sure why the the HUDmaker feels so weird to use with how often things don't save or become uneditable.
Just tried that and i got an error message.
Condition: if (BattleManager.actor() && BattleManager.actor().actorId() === (2) && BattleManager.actor().isInputting())

and got this popup-
View attachment 343001

It's really weird, half of the time i input a condition statement, it doesn't save when i go back - i have to do it a few times to get it to save.
And other times if i try to edit a condition, it doesn't erase so i have to create a different element to get to that point.



Kind of a similar thing happened with the first part of this reply:
View attachment 343002
Not sure why the the HUDmaker feels so weird to use with how often things don't save or become uneditable.
You've inexplicably put the ID in brackets in your first one. Try this, it should hopefully do the trick:

JavaScript:
if (BattleManager.actor() && BattleManager.actor().isInputting() && BattleManager.actor().actorId() === 2)
do they need the IF at all? doesnt the hudmaker condition box use the direct truthy value of what you put in?
You've inexplicably put the ID in brackets in your first one. Try this, it should hopefully do the trick:

JavaScript:
if (BattleManager.actor() && BattleManager.actor().isInputting() && BattleManager.actor().actorId() === 2)
I added the brackets after i got the error popup twice, so i kinda just tried it thinking it could work.

if (BattleManager.actor() && BattleManager.actor().isInputting() && BattleManager.actor().actorId() === 2)
Just tried this after you sent it, and i another error popup similar to the previous ones, so i decided to hit F8 and look in console to see if i could get more details and found this-

1750090929936.png

Wouldn't unexpected end of input mean it needs something to end the statement like a semicolon ;?

do they need the IF at all? doesnt the hudmaker condition box use the direct truthy value of what you put in?
When i remove the IF, the statement turns green, but nothing actually happens, the element doesn't appear at all. I was thinking it might require a $ or a ! since in most of SRD's tutorials, his conditional statements almost always have a $ at the start, but i don't think that's why it's returning an unexpected end of input error.
So i was doing some brainstorming, what if before battles, i set variables for finding the actor ID of each party member.

1750095693848.png

Although i'm not sure how i would script this.

The conditional statement would look through each of the variables, and if any of them have the value of 2, then the graphic would appear.
When i remove the IF, the statement turns green, but nothing actually happens, the element doesn't appear at all
can you ensure that the element shows up in general? if you left the condition blank (or set it to just be true. idk how it handles blank conditions), does your picture show?
can you ensure that the element shows up in general? if you left the condition blank (or set it to just be true. idk how it handles blank conditions), does your picture show?
Yes, so when it's blank or has true it works perfectly, at the moment i have the element set to text that just says test.
You've inexplicably put the ID in brackets in your first one. Try this, it should hopefully do the trick:
However, those brackets quite literally do nothing at all. 5 and (5) are 100% equivalent in every way.

Now, I'm not sure whether I'm missing something here, or everyone else is missing something here. Why are all the code samples comparing the actor ID to a constant? Doesn't it make more sense to do something else with the actor ID? Or even don't bother with the actor ID and just get the actor and grab some data from it?

JavaScript:
let whichPictureId = 1; // Change this value if needed.
if(BattleManager.actor() && BattleManager.actor().isInputting()) {
  let actorData = BattleManager.actor().actor(); // Yes, you need actor() twice.
  let facePic = actorData.meta.battleFacePic;
  let origin = 0, x = 0, y = 0, scaleX = 1, scaleY = 1, opacity = 255, blendMode = 0; // Change these values
  $gameScreen.showPicture(whichPictureId, facePic, origin, x, y, scaleX, scaleY, opacity, blendMode);
} else {
  $gameScreen.erasePicture(whichPictureId);
}

Then you can place a <battleFacePic:SomePictureName> note tag in the actor's note box and it should theoretically all work. The only complication would be where that code is placed. I think it might have to be in a parallel common event? Those do run in battle, right? Maybe it also works in a troop event bound to a switch that is always on. Presumably, it would also work if you aliased BattleManager.update in a plugin and put the code there.
I was just building on the previous suggestion. OP didn't say anything about it not being what they wanted so I figured that was what the goal was.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-find-which-actors-turn-it-currently-is.178353/