[Ace / RGSS3] Window_EquipStatus: Different Stats for Different Actors

Hi all, I have a very beginner question regarding Window_EquipStatus.

To give a very brief explanation, I am using an extremely simple stat model where each actor has a primary attribute (which is either ATK, MDF, AGI, or MAT). Because of this, I only want to show two attributes in Window_EquipStatus: the actor's Max HP, and their primary attribute.

My problem is that I'm having trouble setting up Window_EquipStatus to show different attributes for each individual actor. If anyone can point out what I'm doing wrong, I'd appreciate it!

Here is what I'm currently using:

Edit: I just realized that the code below uses a single "=" after actor_id, rather than "==" -- I'm very used to markup languages, and still learning the basics of RGSS. When I change the "=" to "==", I end up with a blank Window_EquipStatus. Not sure if that is on the right or wrong track, but I just wanted to include that thought.

  #--------------------------------------------------------------------------  # * Refresh  #--------------------------------------------------------------------------  def refresh    contents.clear    draw_actor_name(@actor, 4, line_height * 0) if @actor    if @actor_id = 1      2.times {|i| draw_item(0, line_height * (1 + i), [0,2]) } #ATK    elsif @actor_id = 2      2.times {|i| draw_item(0, line_height * (1 + i), [0,5]) } #MDF    elsif @actor_id = 3      2.times {|i| draw_item(0, line_height * (1 + i), [0,6]) } #AGI    elsif @actor_id = 4      2.times {|i| draw_item(0, line_height * (1 + i), [0,4]) } #MAT    end  end EquipStatus.png
when u open do u get any errors?

and u showed this between actor 1 and 2 does it work with the other two?
You're assigning to the actor id instead of comparing it. Use '==' for comparison, '=' for assignment.


Edit: You really should be using a 'case' statement there instead of an 'if', by the way.
Thanks. I noticed the '==' error shortly after posting... Anyway, what I get with '==' is a blank window, aside from actor_name.

  #--------------------------------------------------------------------------  # * Refresh  #--------------------------------------------------------------------------  def refresh    contents.clear    draw_actor_name(@actor, 4, line_height * 0) if @actor    if @actor_id == 1      2.times {|i| draw_item(0, line_height * (1 + i), [0,2]) }    elsif @actor_id == 2      2.times {|i| draw_item(0, line_height * (1 + i), [0,5]) }    elsif @actor_id == 3      2.times {|i| draw_item(0, line_height * (1 + i), [0,6]) }    elsif @actor_id == 4      2.times {|i| draw_item(0, line_height * (1 + i), [0,4]) }    end  endEquipStatus2.png
Well, admittedly, I didn't notice that you were trying to use @actor_id, either. That instance variable doesn't exist, so it returns nil (which will turn into an empty string when converted into one). Use @actor.id instead.
Awesome. Thank you! Just switching from @actor_id to @actor.id gave me an error, but I borrowed from the above draw_actor_name and ended up with this, which works:

Code:
  #--------------------------------------------------------------------------  # * Refresh  #--------------------------------------------------------------------------  def refresh    contents.clear    draw_actor_name(@actor, 4, line_height * 0) if @actor    if @actor and @actor.id == 1      2.times {|i| draw_item(0, line_height * (1 + i), [0,2][i]) }    elsif @actor and @actor.id == 2      2.times {|i| draw_item(0, line_height * (1 + i), [0,5][i]) }    elsif @actor and @actor.id == 3      2.times {|i| draw_item(0, line_height * (1 + i), [0,6][i]) }    elsif @actor and @actor.id == 4      2.times {|i| draw_item(0, line_height * (1 + i), [0,4][i]) }    end  end
Edit: Thanks for your advice about the case tag. I'm guessing that the above code is not optimized, so I'll look into that next. Thanks again for your help.
Using the 'case' statement isn't really so much about performance as it is about readability. It does essentially the same thing that you're doing, but honestly, it's easier to look at than a block of 'if' and 'elsif' statements. It's really a matter of personal opinion, though the larger Ruby community outside of RPG Maker would consider the 'case' statement more... idiomatic. Use whatever you find most comfortable, really.
Looks like you got it already, but if you want an example of code that's a bit more manageable (and with a case statement), I'd go with this setup.

Code:
  #--------------------------------------------------------------------------  # * Refresh  #--------------------------------------------------------------------------  def refresh    contents.clear    return unless @actor    draw_actor_name(@actor, 4, 0)        case @actor.id    when 1; params = [0,2]    # Actor 1    when 2; params = [0,5]    # Actor 2    when 3; params = [0,6]    # Actor 3    when 4; params = [0,4]    # Actor 4          else      params = [0,2] # Default    end         params.each_with_index { |param_id, i|       draw_item(0, line_height * (1 + i), param_id)    }  end
I really appreciate the help Solistra and Mr. Bubble; I wasn't expecting such thorough replies to a rookie question. Thank you both for taking the time.

Original thread: https://forums.rpgmakerweb.com/threads/ace-rgss3-window_equipstatus-different-stats-for-different-actors.16500/