Issue with Fhizban's Party HUD

I'm using Fhizban's party HUD script in my game to display the player's HP in the corner of the screen, and up until now it's been working perfectly. A couple of times in the game I've swapped which party member is active, but it's only now I've reached a section with two party members at once I'm getting problems. When I try to remove one of them, I get the following error:

Script 'FHIZBAN'S PARTY HUD' line 58: NoMethodError
occurred.
undefined method 'hp' for nil:NilClass

I feel pretty sure it has something to do with having more than one party member, but I'm no scripter, so I don't really know how to solve this. If I can't find a way to make it work and allow me to remove party members, the only way I'm going to be able to make this game is to not have party members, which will make the lategame much less interesting.

Here's what seems to be the relevant part of the script, I would really appreciate any help with this!

def fhiz_hud
i = 0
while i < @party_size
@actor = $game_party.members
@actor_hp = @actor.hp
@actor_mp = @actor.mp
i += 1
end
i = 0
while i < @party_size
@actor = $game_party.members
@x = OFFSET_X + (WIN_WIDTH + OFFSET_X)*i + (PADDING*i)
@y = OFFSET_Y
if DRAW_FACE
if @actor_hp > 0
draw_actor_face(@actor, @x, @y, true)
else
draw_actor_face(@actor, @x, @y, true)
end
end
if DRAW_NAME
draw_actor_name(@actor, @x, @y)
end
if DRAW_STATES
draw_actor_icons(@actor, @x, @y+(WIN_HEIGHT-line_height*4), WIN_WIDTH)
end
if DRAW_HP
draw_actor_hp(@actor, @x, @y+(WIN_HEIGHT-line_height*3), WIN_WIDTH)
end
if DRAW_MP
draw_actor_mp(@actor, @x, @y+(WIN_HEIGHT-line_height*2), WIN_WIDTH)
end
i += 1
end
end
Change the script to include these few lines.
Ruby:
  def find_party_size
    @party_size = $game_party.all_members.size
  end
  #=============================================================================
  #
  #=============================================================================
  def fhiz_hud
    i = 0
    find_party_size
    while i < @party_size
      @actor = $game_party.members[i]
I included a few lines from the script so you know where to put the lines
Thanks so much for your help! Unfortunately I think I must still be missing something, as when I try to launch the game I now get this error.

Script 'FHIZBAN'S PARTY HUD' line 141: SyntaxError
occurred.
unexpected $end, expecting keyword_end

It's at this part of the script. 141 is the final line.


#===============================================================================
#Show the window on the map
#===============================================================================
class Scene_Map < Scene_Base
alias original_create_all_windows create_all_windows
def create_all_windows
original_create_all_windows
create_face_window
end
def create_face_window
@face_window = Window_Fhiz_Hud.new
end
end

#===============================================================================
I must still be missing something
Probably because you added that text somewhere in the script and not in the correct location. I did not give you an addon or a piece to insert cleanly.
I gave a reference to where you need to change the code. Every line that is not in the script you can add in.
So that would be the 3 lines for def find_party_size, and the one line inside def fhiz_hud
Yeah, you're right. I replaced the previous 'end' when I wasn't supposed to. Thanks again, the problem is fixed now c:

I've moved this thread to Script Support. Thank you.


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.

Original thread: https://forums.rpgmakerweb.com/threads/issue-with-fhizbans-party-hud.128935/