RMMV - Get Selected Actor's ID Using Variables?

Hello World,

Forgive me if this question has already been answered, I am new to RPG Maker. I am trying to use Variables and Common Events to accomplish a monster evolution event using an item that calls on a common event. In the common event, I am trying to have logic get the SELECTED party member's ID that is not predetermined in the party. I see Game Data has only predetermined slots to assign. Is there a way I can use a script to find a selected party member's ID, such as
"$gameParty.members()[p]._actorId" ; where [p] can be changed to something else other than a set position in the party? Perhaps there is a better way to do this...

I thank you in advance for your help.
Hello!

The trick to doing this in events is that common events in the Effects of Items and Skills run after the item has resolved everything it does - at that point, the game doesn't know who you used it on (which is of varying truth depending on whether you're using this in battle or the menu, but this way is guaranteed to work).

The common workaround is:
1 - Make a State that doesn't do anything

2 - In the Effects of the item, apply that state

3 - Make conditionals that look at each party member and say "If this actor has my new state on, set my variable to their actor ID" (you could make this part smaller with a script call, if you know JavaScript)

4 - Remove the state from that actor

5 - End the conditional and do the rest of your event on that actor ID.
Hello!

The trick to doing this in events is that common events in the Effects of Items and Skills run after the item has resolved everything it does - at that point, the game doesn't know who you used it on (which is of varying truth depending on whether you're using this in battle or the menu, but this way is guaranteed to work).

The common workaround is:
1 - Make a State that doesn't do anything

2 - In the Effects of the item, apply that state

3 - Make conditionals that look at each party member and say "If this actor has my new state on, set my variable to their actor ID" (you could make this part smaller with a script call, if you know JavaScript)

4 - Remove the state from that actor

5 - End the conditional and do the rest of your event on that actor ID.
This was tremendously helpful, thank you for taking the time and helping me understand how to use states to imitate a script call. I am not too familiar with Java; yet I am trying to exercise the programming part of my brain. For now I will use the engine while I attempt to understand java script. Thank you again.
I am not too familiar with Java;
familiarity with Java won't help you anyway, because no maker currently uses any Java.

There is a saying among programmers: Java is to Javascript as ham is to hamster.

or in other words: they have nothing to do with each other but the same letters at the beginning of the word.

And whenever someone new to programming mixes that up, it needs to be pointed out before you learn the wrong language and get confused because nothing works.
familiarity with Java won't help you anyway, because no maker currently uses any Java.

There is a saying among programmers: Java is to Javascript as ham is to hamster.

or in other words: they have nothing to do with each other but the same letters at the beginning of the word.

And whenever someone new to programming mixes that up, it needs to be pointed out before you learn the wrong language and get confused because nothing works.

You just saved me a lot of trouble. My ignorance on the matter is apparent. Thank you for clarifying. I saw in a previous post that in order to best understand programming, you need to focus on logic structures, otherwise you run the risk of knowing tricks without understanding reason. I'm sure I can say that we newbies appreciate the feedback you provide.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-get-selected-actors-id-using-variables.147796/