Setting number of actors in the party to a variable

● ARCHIVED · READ-ONLY
Started by Manofdusk 6 posts View original ↗
  1.  I've been running into several problems as of late trying to get my Tactical Movement system to work.

     With a lot of help, I'm now able to set the Actor IDs to a variable based on what location they are in the formation.

     However, if you try to reference a formation slot that does not exist, the game crashes (no method for nil:NilClass exception)

     so, what I've been working on for quite a few hours now (with no success) is to determine the current party size and set THAT to a variable, using it to make sure the game isn't trying to reference a formation index that (apparently) doesn't exist.

     unfortunately, I can't seem to find anything that I can use that can check it without crashing.

    I've tried:

    $game_party.all_members[x].id

    $game_party.all_members[x].size

    $game_party.all_members[x].index

    $game_party.id

    $game_party.size

    $game_party.index

    $members[x].id

    $members[x].size

    $members[x].index

    $members.id

    $members.size

    $members.index

    I even tried this:

    $if game_party.all_members[1].id exists

    and

    $if game_party.all_members[1].exists

     but it says that 'exists' is undefined.

    ----------

     I also tried these:

    $game_variables[1051] = $game_party.size

    $game_variables[1051] = $game_party.index

    $game_variables[1051] = $members.index

    $game_variables[1051] = $members.size

     so yeah, I've tried everything I know of. Anyone know of some code I could use to set the current number of actors in the party to a variable?
  2. close

    $game_party.all_members.size

    all_members doesn't take an index
  3. All members DOES take an index, but giving it an index gives you an actor back, and actors don't have a size property.


    all_members is an array - you can ask for its size (as you've done), or ask for an element (which the OP has done by giving it an index).


    In fact, Manofdusk, there is an Event Command (Control Variables) that tells you the party size (Game Data > Other, I think). Since you can get it via an event command, that means you can look at Game_Interpreter to find the script call it uses to execute that event command.


    If you want to do stuff like this in future, I suggest you either take a look at Game Interpreter, or at the pinned thread in the VX Ace Support forum that lists the script equivalents of event commands :)
  4. my bad, missed .size on the last sentence but yeah shaz is right, there is an event command for it.
  5.  part of me is relieved that an event command exists.... and part of me is frustrated that I spent 7 hours working on it without knowing :(

     but thanks. I'll go find that thread and save it to favorites.
  6. :) Think of all the things you learned in the process.


    Really - take a GOOD, LONG look at Control Variables, especially in the Game Data section. It's HUGE!


    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.