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.

$game_party.actors[i] = nil?

Hi,

I have an odd problem. When I do "p $game_party" I get info that suggests that there IS an 'actors':

#<Game_Party:0x7d63bf8 @gold=0, @steps=0, @armors={}, @grid_points={0=>0, 1=>0}, @actors=[#<Game_Actor:0x7d63118 @armor4_id=35, @actor_id=1, [.....]

Then if I do "p $game_party.actors" I got one with @actor_id==1.

But then if I do "p $game_party.actors[1]", it returns nil. Wtf? o_o What could the problem be? I have too many (original) scripts to name, so if you could help me out with where to look (e.g. for '@actors = []' or something) then I'll search for it.^^ Because I have absolutely no clue what the cause could be. Thank you!

Help appreciated mucha. :D
 
$game_party.actors is an Array, and the min index of an Array is 0, not 1.
So, for pointing the first actor you have to do: "$game_party.actors[0]"
"$game_party.actors[1]" points to the second actor of that array.
 
Yeah, actor id, and the index of the actor in the party are two different things. the actor id is the number of teh character in the database, while the index is the number of the character in the party. (Minus one, so that the minimum index is 0.) For instance, the character with id 15 could be the 0th character in the array.
 

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