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

41728280

Veteran
Veteran
Joined
May 31, 2020
Messages
240
Reaction score
74
First Language
Chinese
Primarily Uses
RMMV
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;_;
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,140
Reaction score
3,191
First Language
EN
Primarily Uses
RMMZ
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.) :)
 

41728280

Veteran
Veteran
Joined
May 31, 2020
Messages
240
Reaction score
74
First Language
Chinese
Primarily Uses
RMMV
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 code2222222.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
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,140
Reaction score
3,191
First Language
EN
Primarily Uses
RMMZ
Huh, strange. :kaoslp: 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>
 

41728280

Veteran
Veteran
Joined
May 31, 2020
Messages
240
Reaction score
74
First Language
Chinese
Primarily Uses
RMMV
Huh, strange. :kaoslp: 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! :thumbsup-right:
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!:guffaw:
 

Latest Threads

Latest Profile Posts

ScreenShot_12_7_2022_8_57_56.png
part of the common event help menu I'm working on. I used Yanfly's Common Event Menu to set it up and here's a screen of once you've selected one of the options. This one explains the 6 different battle commands.
KDS
Hey guys! Iam currently updating my free digital art shop , let me know if you need anything done :) https://forums.rpgmakerweb.com/index.php?threads/kds-free-open-digital-art-shop.17097/
Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!

Forum statistics

Threads
127,106
Messages
1,184,019
Members
167,033
Latest member
Biaxciss
Top