Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Get actor ID from position in party

BEFORE YOU REPLY: I am not looking for something like
Code:
$game_variables[1] = $game_actors[3].index

No. What that script does is, given the actor's ID, the game will figure out it's position in the party.

I would like a script that does the vice versa of that in VX: Given the position in the party, the game will figure out what the ID of the actor occupying that slot is. I don't know if this already exists, I tried googling it, but I came up with nothing.
 
You have to check $game_party.members (or $game_party.actors for XP, just for information), which holds your current party's employees. To check for the id in a specific spot, use this:
Code:
$game_party.members[3].id # returns ID of party actor #3
Please ask if you have any more questions regarding this.


Also, this belongs to RGSS Support, not Script Request, as it's a function question, not a request for a whole system or whatnot.
 
BlueScope":1s0fa2hh said:
You have to check $game_party.members (or $game_party.actors for XP, just for information), which holds your current party's employees. To check for the id in a specific spot, use this:
Code:
$game_party.members[3].id # returns ID of party actor #3
Please ask if you have any more questions regarding this.


Also, this belongs to RGSS Support, not Script Request, as it's a function question, not a request for a whole system or whatnot.

Hmm. Well I tried
Code:
$game_variables[102] = $game_party.members[1].id

but that doesn't seem to be working. It doesn't put a numberical value into the variable and just gives me a bunch of glitchy stuff.
 
Hm... for all I know, VX isn't quite as easy on setting $game_variables as XP was... for example, you can't set them to hold strings anymore. However, as the ID is a pure integer, I wouldn't know why it doesn't work... to be sure, put this instead to check on the 'pure' output before any special rules will be applied:
[rgss]p $game_party.members[1].id
$game_variables[102] = $game_party.members[1].id # very same line
[/rgss]
If that outputs a readable value, try this:
[rgss]$game_variables[102] = $game_party.members[1].id.to_i # not very same line
[/rgss]

Other than that, it goes without saying that you have to have an actor in your party to do this... but I guess you figured that out by yourself ^^" (reminds me you might want to check for that when executing your script...)

If that doesn't work, please let me have a look at the 'glitchy' stuff.
 

Atoa

Member

Also remember that indexes start at 0.

So the first member is index 0, the second index 1....

ID of the first member:
$game_variables[102] = $game_party.members[0].id
 
True, I was thinking database items, which start at 1 ^^" Thanks for the correction.
This applies for the variables, though: $game_variables[102] will actually be #102 in the variable list.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top