Need help with correct syntax. Setting game_party to variables

● ARCHIVED · READ-ONLY
Started by Manofdusk 9 posts View original ↗
  1.  I had a thread of this in the support thread but the original question was answered and I think I would have a better chance of getting the follow up question answered here:

     I'm trying to set the game_actor in the game_party to a variable (so that each variable can be used to hold a game_actor's ID based on where it is in the formation at any given time). Using this, I can then set up Common Events that will let the player control multiple parties on the same map.

     Unfortunately, I have little understanding of Ruby Script so I'm really not sure of the syntax.

     here's what I'm guessing at:

    if $game_party.members[x] == $game_actors[y];

      $game_variables[z] = y;

     else;

     end;

    naturally, I would be changing the x, y, and z to the actual IDs of the game_party and game_actors.

     Also, anyone know if the game_party.members index starts at 0 or 1?
  2. $game_party.members starts at 0.


    $game_actors starts at 1.


    You might be better off using $game_party.all_members as members gives you a different list depending on whether you are in battle or not.
  3. does $game_party.all_members start at 0 too?

    is this:

    if $game_party.members[x] == $game_actors[y];

      $game_variables[z] = y;

     else;

     end;

     the correct syntax?
  4. Since you have the idea in mind, why not try it out yourself first? 

    anyway, that should work fine... though no need for the semicolons and that else part unless you're putting something in there
  5. You don't need to look up the actor just to compare it with the member.


    You can do this:

    if $game_party.all_members[0].id == 5instead this:
    Code:
    if $game_party.all_members[0] == $game_actors[5]

    However, there are already methods in the class to do what (I think) you're trying to do.


    If you simply want variables 1-10 to contain the actor id in the corresponding location in the lineup, try this:

    Code:
    $game_party.all_members.each_index {|i| $game_variables[i+1] = $game_party.all_members[i].id}
    If you want to start at variable 18 instead, you'd do $game_variables[i+18]
  6.  well, I tried that using a simple setup and got the following error:

    Script 'Game_Interpreter' line 1411: NoMethodError occurred.

    undefined method 'id' for [0]: Array

     not sure what that means. If it matters, I didn't change the 'i' to anything. I just copied it strait.

    $game_party.all_members.each_index {|i| $game_variables[i+1] = $game_party.all_members.id}

     to be honest, I want the first 50 variables to be set to where an actor is in the formation (I don't know if that changes the formula or would break the game if there were less than 50). The idea is to allow players to control up to 10 units (of 4 or 5) at once. If I ever get this part finished, I plan on making a separate common event for groups of 4, and 5
  7. Does a variable represent an actor and their position in the party, or the position in the party, and the actor id occupying that position?


    So variable 1 is linked with actor 1, and if they're 4th in line, it will contain the value 4?


    Or variable 1 is linked with the first party member, and if actor 8 is the leader, variable 1 will be set to 8?


    Are you saying you can have up to 50 in your party at one time?
  8. variable 1 is linked with the first party member and if actor 8 is the leader, Variable 1 will be set to 8.
     That's how I planned on doing it.... and yes, I was planning on having this template support up to 50 party members at once (it's supposed to be the template for a squad based tactical rpg)

     Here is a youtube video of roughly what I want to make a template for:

    https://www.youtube.com/watch?v=20ISriddgpw

     you can skip to 2:30 for the actual gameplay and 5:15 for combat. That said, I doubt I can pull off ALL of the functionality of that.... but using the variables, I can empty the party using a common event and then fill the party with the appropriate characters based on which variables have which actors stored in them (and their position in the party will be preserved). Which squad's "turn" it is will be determined by 10 switches. One switch turns on, the other 9 turn off, the common event runs based on which switch is on at any given time (thus emptying the party and putting the party members back in based on which variables are active).

     If switch 1 is on, it empties the party then fills it with members 1-4 (based on the formation variables). If switch 2 is on, it empties the party then fills it with 5-8, ect.

     I'll be setting up events for each squad and using a parallax event to record the player's location based on which switch is on as well, allowing me to use Transfer player to accurately transport the player from squad to squad as you control the party. I may need a little help with this later, after I get the formation variables worked on.

    -----------------------------------------

     I do plan on releasing the template once it's done (using only minimal modification) so that anyone who wants to make one will have a premade template for squad based Tactical RPGs.
  9.  I still need to know what this means.

    undefined method 'id' for [0]: Array

     unfortunately, I never learned how to use arrays so I don't know how to troubleshoot this one.

    --------------------------------------------

    EDIT: well, I decided to try this:

    if $game_party.all_members[x].id == y

     $game_variables[y] = y

     and came up with this error:

    undefined method 'id' for nil:NilClass

    ---------------------------------------------

     It happens when it tries to call a formation for a slot that doesn't have an actor in it.

     I tried adding this:

    if $game_party.all_members[0].id == nil
       $game_variables[1001] = 0
       end;

     the idea was to set the variable to 0 if it tried to call a formation slot that didn't have an actor in it (and keeping it from throwing an error). Unfortunately, that didn't work.

     I need some way to keep it from throwing an error. I'm assuming I need to set event handling if the slot doesn't exist... but I don't know how to do that (that was partly what I was trying to do by setting the variable to 0).