So, to test, I had 5 characters in my party (and 4 active), and I set variable 1 to $game_actors[-1].hp then called \V[1], which returned with the HP of the 5th member, so I'm like what? and I try $game_actors[-2].hp which returns with member 4's HP, so again, I'm confused. I heard that [-1] means member 1, [-2] means member 2, and soforth.
Yet I testplay with only 4 characters in my party, and $game_actors[-1].hp returns with the HP of member 1's.
How would I get the HP of the actor in Slot 1 regardless of the number of people in my party? So it's almost like when I have members in the reserves, it messes up.
And is there a way to get say index[1]'s Actor ID?
- index makes you read backwards... -1 returns the index at the last spot...
also $game_actors is for the actual actors that are already initialized and uses the ID the same as the ID on the database. if you want to fetch data of the party members, you should use $game_party.members
$game_party.members[0] returns the leader... [1] returns the next member and so on
to get the id, I think
$game_party.members[0].id should work
Why would you use -1 and -2?
Arrays in Ruby start at 0. However database items use the number that appears beside them in the database tab as the index (they have a nil first element).
If you use a negative number, it counts from the end of the array instead of the beginning.
So if you want Actor 1, you'd use $game_actors[1]. This is the person shown as Actor 1 in the Actors tab - it is NOT the first person in your party lineup. For that, you would need to use $game_party.members[0] or $game_party.leader
$game_actors does not deal with the party order, rather the id assigned in the database list. If you want the party member's HP or other stats, use $game_party.members[index].
Additionally, a negative index will start counting from the back rather than the front. Wherever you learned that negative values would be the same as positive was incorrect, except perhaps in a case specifically made to work that way.
I think he learned it from a custom script... some scripts the deal with handling both player character and events uses - index to denote party members and positive index to denote events... so I think he took it as how the engine handles indexes by default. I saw that I think on the particle engine, and as such implemented the same method for my lighting script for example...
Thanks.
$game_party.members[0].actor.id works, yup.
So that's Index [x]'s Actor ID.
And $game_actors[x].index means given actor's slot id
yep, sounds like you've got it nailed 😉
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.