Simple Script Question (Get Actor ID #)

I'm sorry if I'm posting this in the wrong place, but I read through the topics, and couldn't figure out which section was appropriate. I just need to know what script I need to use for MZ to set a variable to an actor's ID. I know that's ridiculously simple to some of you, but I'm still learning the ins and outs of this system.

Thanks for the help! 🙂
none?
use the "set variable" command, from the list.
set it to "game data", then "actor", right next to it should be ID.

I've moved this thread to RPG Maker MZ Support. Thank you.

Also, consider writing a more descriptive thread title in future: "Simple Script Question" is much less informative than something like "Get Actor ID"~ 👋
Also, consider writing a more descriptive thread title in future: "Simple Script Question" is much less informative than something like "Get Actor ID"
You're right, I should have been more specific in my title. Thanks for the help.

none?
use the "set variable" command, from the list.
set it to "game data", then "actor", right next to it should be ID

Thank you for the response. I followed your instructions, but ran into the same problem. Under "Game Data" there are two options:
1. Party -- This gives the option to set Actor ID to whatever combat position the actor is in, which is not what I'm looking to do.
2. Actor -- This allows you to select a specific attribute for the actor. You can set the variable to the actor's level, XP, HP, MP, etc, but there is no option to select the actor's ID.

As far as I can tell, there is no option to simply set a variable to the ID# of an actor.
I am still learning myself, but I think something like this would work:


$gameVariables.setValue([insert variable ID here], [insert Actor ID here])

e.g.

$gameVariables.setValue(3, 1)

with that, I believe, the specified variable should obtain the specified actor ID. I could be way off, but I'd give it a shot.
As far as I can tell, there is no option to simply set a variable to the ID# of an actor.
The thing that makes this not an immediately easy answer is the lack of context. But the pertinent functions are:
Code:
$gameVariables.setValue(variableID, value);

and
Code:
actor.actorId()

So if you have a JavaScript variable for an actor someplace, and you want to store that into a game variable, you'd do:
Code:
$gameVariables.setValue(variableID, actor.actorId());
where variableID is, of course, the number ID of the game variable.
The thing that makes this not an immediately easy answer is the lack of context. But the pertinent functions are:
Code:
$gameVariables.setValue(variableID, value);

and
Code:
actor.actorId()

So if you have a JavaScript variable for an actor someplace, and you want to store that into a game variable, you'd do:
Code:
$gameVariables.setValue(variableID, actor.actorId());
where variableID is, of course, the number ID of the game variable.
So to clarify (to make sure I understand), not enough context would depend on the situation you're in? For example, whether I was calling this inside or outside of combat?

I am creating a "dual tech" function (for those of you familiar with Chrono Trigger), and when the player selects the option, I have to do a check to make sure that the appropriate actor is in the active battle party (since my game has more than four actors), else, the ability will cancel or fail. Being able to set a variable to an actor's ID would help me cut down on the amount of "If-Else" statements I would need in the script (since there are no "AND" or "OR" options in the menu).

So the function is $gameVariables.setValue(X,X).
The first X should be ID# of the variable to be set.
The second X should be the function "actor.actorid()," which sets the variable to the actor's ID#.

If I understand this correctly, I should be able to use "actor.actorid()" to assess which party members are in which slot when a dual tech is selected. I hope I understood that right. It's going to take a while before I can test this to make sure it all works.

Thanks for all your help. 🙂
The thing that makes this not an immediately easy answer is the lack of context. But the pertinent functions are:
Code:
$gameVariables.setValue(variableID, value);

and
Code:
actor.actorId()

So if you have a JavaScript variable for an actor someplace, and you want to store that into a game variable, you'd do:
Code:
$gameVariables.setValue(variableID, actor.actorId());
where variableID is, of course, the number ID of the game variable.
I was close...kinda lol
So to clarify (to make sure I understand), not enough context would depend on the situation you're in? For example, whether I was calling this inside or outside of combat?
No, depending on the exact function you're calling it inside of. No offense (because you surely know this), but you're trying to do stuff that you don't understand, so you need to give us more information to help you.
So the function is $gameVariables.setValue(X,X).
The first X should be ID# of the variable to be set.
The second X should be the function "actor.actorid()," which sets the variable to the actor's ID#.
No, there is every chance that will fail. When I typed the word "actor," that is referring to a variable of the type Game_Actor. It might be called actor, it might be called user, it might be called mog_chrono_attacker, I have no idea. And if you don't know JavaScript well enough to determine that, you'll just be grasping at straws. And you also didn't copy the capitalization properly, which means you wouldn't actually be calling the function.

I have to do a check to make sure that the appropriate actor is in the active battle party...Being able to set a variable to an actor's ID would help me cut down on the amount of "If-Else" statements I would need in the script
And that's what I mean by context 😉 If you'd provided that information in the first post, you would've been told that you don't need to do any ifs, elses, or set a variable to anything. You can simply check whether a specific actor is in the battle party with this line:
Code:
$gameParty.battleMembers().includes($gameActors.actor(X))
where X is the ID of the actor you're checking. So if you're doing this from within an event, you can just do Conditional Branch -> Script and paste that in.

Original thread: https://forums.rpgmakerweb.com/threads/simple-script-question-get-actor-id.142404/