MV In battle, how to assign the current actorId to a variable?

Hi, hope someone can help me. :LZSsad:
I need to get the value of the current actorId in <setup action> when executing the action sequence of yanfly in battle, and then assign this value to a game variable 10, and then I want to call the public in <target action> Event, this event needs to change the effect according to the current actorId.
How to get this actorId? Then assign to variable 10?
Thank you all in advance;_;
With Action Sequence Pack 1 it looks like you might be able to do something like this (untested):
Code:
change variable 1 = user.isActor() ? user.actorId() : 0
Alternatively you could try this:
Code:
eval: $gameVariables.setValue(1, user.isActor() ? user.actorId() : 0);
(Both of these are actions, i.e. they'd go in your <setup action> tag block.) 🙂
With Action Sequence Pack 1 it looks like you might be able to do something like this (untested):
Code:
change variable 1 = user.isActor() ? user.actorId() : 0
Alternatively you could try this:
Code:
eval: $gameVariables.setValue(1, user.isActor() ? user.actorId() : 0);
(Both of these are actions, i.e. they'd go in your <setup action> tag block.) 🙂
Hi, caethyril!
I added the code you gave to <setup action> and tested them separately
The first code went wrong when the actor attacked
This is the console screenshot of the first code
2222222.png


The second code does not seem to return the actorID value to the variable, so calling the event has no effect. This is a screenshot of me using the console to view variables :LZSsad:
111.png
Huh, strange. 😴 Looks like the colon : is the problem: it's cutting off the eval, which causes the "unexpected end of input" error for my first suggestion...I guess it's the same problem for the second suggestion, too. (I assume it's a quirk of Yanfly's action-tag parser, haven't looked into it deeply.)

I just tried this and it seemed to work OK for me~
Code:
<setup action>
perform setup
if user.isActor()
  change variable 1 = user.actorId()
else
  change variable 1 = 0
end
</setup action>
Huh, strange. 😴 Looks like the colon : is the problem: it's cutting off the eval, which causes the "unexpected end of input" error for my first suggestion...I guess it's the same problem for the second suggestion, too. (I assume it's a quirk of Yanfly's action-tag parser, haven't looked into it deeply.)

I just tried this and it seemed to work OK for me~
Code:
<setup action>
perform setup
if user.isActor()
  change variable 1 = user.actorId()
else
  change variable 1 = 0
end
</setup action>
Thank you very much! Now it can work normally! 👍
I only have a little JS foundation. I know that it is a relatively simple way of writing ternary expressions. Perhaps this way of writing is not supported in the sequence, and I don't want to know more about it. The normal way of writing is very effective.
Thanks again for your help! Cheers!🤣

Original thread: https://forums.rpgmakerweb.com/threads/in-battle-how-to-assign-the-current-actorid-to-a-variable.126613/