Retrieve All Actors

So, I was looking at the script call list featured here:




I was wondering if there was a way to obtain every actor in the game?


I tried this (using common sense, since it isn't mentioned in the list) but the game crashes:

Code:
for (var i = 0; i < $dataActors.length; i++) {
  if (!!$dataActors[i]) {
    if ($dataActors[i].name.length > 0) {
      $gameParty.addActor($dataActors[i]);

    }
  }
}
This works for me to give all actors into my party... granted I only have 4, so I dont know if it would freak out if you have more actors, and Im not able to test anything extra right now.


for (var i = 1; i < $dataActors.length; i++) {
$gameParty.addActor(i)
$gamePlayer.refresh();
$gameMap.requestRefresh();
}


Note the "var i =1" is needed instead of i = 0 cause it would cause a crash cause there is no actor with an ID of 0
This works for me to give all actors into my party... granted I only have 4, so I dont know if it would freak out if you have more actors, and Im not able to test anything extra right now.



for (var i = 1; i < $dataActors.length; i++) {
$gameParty.addActor(i)
$gamePlayer.refresh();
$gameMap.requestRefresh();
}


Note the "var i =1" is needed instead of i = 0 cause it would cause a crash cause there is no actor with an ID of 0

Yep, it works.
Glad to help! 😀
Glad to help! 😀

I have about 30 actors in my game. :3
Good lord!  No wonder you wanted to do that by script call, lol
Good lord!  No wonder you wanted to do that by script call, lol

Yeah.
Good lord!  No wonder you wanted to do that by script call, lol

The reason I have this many actors is because one of the characters has a special power which allows him to change forms.

Original thread: https://forums.rpgmakerweb.com/threads/retrieve-all-actors.65240/