Determining the number of actors in a battle

Is there a simple method to return the number of actors currently in a battle?


I recently changed my variable gathering script to return the information about each actor based upon their index number instead of their name. That way, if the protagonist is not in a battle, the game will return the stats of whoever is in slot 0 and react accordingly, instead of being unable to find the protagonist.


The problem there, however, is that I need to make sure the game isn't trying to load the data of, say, actor #3 when there's no actor there to load.


Is there a JS variable that I could follow the path of in order to acquire the number of actors in a battle?


Thanks in advance!
I am not sure if i understand correctly, but use this


$gameActors.actor($gameParty.members()[0].actorId())


this will return index to id
If you're in battle and want a count of ALL battle members (alive or dead), use $gameParty.members().length


If you're out of battle and want a count of ALL battle members (alive or dead), use $gameParty.battleMembers().length (this can also be used if you're in battle)
If you're in battle and want a count of ALL battle members (alive or dead), use $gameParty.members().length


If you're out of battle and want a count of ALL battle members (alive or dead), use $gameParty.battleMembers().length (this can also be used if you're in battle)



Worked like a charm.


Thanks so much! 😀

Original thread: https://forums.rpgmakerweb.com/threads/determining-the-number-of-actors-in-a-battle.65575/