Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Help modifying Yeyinde's HUD

After a long time reading it, i finally think i Understood how to make a basic HUD.
But now I want to add some features, so I need your help.
Btw, I dont know how to make spoilers, or put my codes in the cool code thing, so I would appreciate help with that too. :)

Here's my code.
Basically copy and pasted, with slight modifications.

Code:
class Window_YourHUD < Window_Base
  def initialize
    super(0, 0, 350, 64)
    self.contents = Bitmap.new(350 - 32, 64 - 32)
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if !@actor
    draw_actor_hp(@actor, 0, 0)
    draw_actor_sp(@actor, 150, 0)
  end
  def reset_variables
    @actor = $game_party.actors[0]
    @old_hp = @actor ? @actor.hp : 0
    @old_maxhp = @actor ? @actor.maxhp : 0
    @old_sp = @actor ? @actor.sp : 0
    @old_maxsp = @actor ? @actor.maxsp : 0
  end
  def update
    super
    refresh if (@actor = $game_party.actors[0] or
                @old_hp = @actor ? @actor.hp : 0 or
                @old_maxhp = @actor ? @actor.maxhp : 0 or
                @old_sp = @actor ? @actor.sp : 0 or
                @old_maxsp = @actor ? @actor.maxsp : 0)
  end
end
class Scene_Map
  alias yourhud_main main
  alias yourhud_update update
  def main
    @yourhud = Window_YourHUD.new
    yourhud_main
    @yourhud.dispose
  end
  def update
    @yourhud.update
    yourhud_update
  end
end

I wanted it justified to the top left, and I managed to do that.
Now I need help adding the character's name to it.
I know I'll be using \n[1], but idk where.
Since I can't have it on during battles and cutscenes and such, I need to be able to turn it off as well. Like, make it reliant on a switch or something.
I also want to add icons near the words HP and SP, like potion bottles or something.
Lastly, I want the current level to be displayed as well.

Any help would be greatly appreciated, and I'm sure this would help many of the n00bs like me trying to make custom HUDs
Thanks. :thumb:
 
For the character's name, somewhere in def update:

@name = $game_party.actors[0].name
self.contents.draw_text(x position, y position, width, height, "#{@name}")

Height is generally 32 I think.

To turn it on/off:

In def update:

self.visible = $game_switches[1]

Where 1 is the number of your switch. (I think that should work).
 
Thanks for the help Wyatt.
Being able to turn it off was the most important thing.
I didnt really understand how to do the name though... :(
Could you please elaborate?
Anyone want to help with the icon or level displays?
I will post my finished script here for public use.

Btw, don't want to sound dumb, but how do you make code in a code section; and how do you make spoilers?
 

Anonymous

Guest

For code
[ CODE ]type code here[ /CODE ]
Without the spaces either side of the [ and ]
For spoilers
[ spoilers ]type message here[ /spoiler ]
Again without the spaces either side of the [ and ]
 

Anonymous

Guest

Where on the hud do you want the level to be visible? on the far right or underneath other visible attributes?

Code:
class Window_YourHUD < Window_Base
  def initialize
    super(0, 0, 400, 64)
    self.contents = Bitmap.new(350 + 5, 64 - 32)
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if !@actor
    draw_actor_hp(@actor, 0, 0)
    draw_actor_sp(@actor, 150, 0)
    draw_actor_level(@actor, 300, y)
    end
  def reset_variables
    @actor = $game_party.actors[0]
    @old_hp = @actor ? @actor.hp : 0
    @old_maxhp = @actor ? @actor.maxhp : 0
    @old_sp = @actor ? @actor.sp : 0
    @old_maxsp = @actor ? @actor.maxsp : 0
    @old_level = @actor ? @actor.level : 0
    end
  def update
    super
    refresh if (@actor = $game_party.actors[0] or
                @old_hp = @actor ? @actor.hp : 0 or
                @old_maxhp = @actor ? @actor.maxhp : 0 or
                @old_sp = @actor ? @actor.sp : 0 or
                @old_maxsp = @actor ? @actor.maxsp : 0
                @old_level = @actor ? @actor.level : 0)
  end
end
class Scene_Map
  alias yourhud_main main
  alias yourhud_update update
  def main
    @yourhud = Window_YourHUD.new
    yourhud_main
    @yourhud.dispose
  end
  def update
    @yourhud.update
    yourhud_update
  end
end

This is for the Level being displayed on the right end of the hud, if you want it displayed in any other way just let me know.

Icons: what do you have in mind? how do you want the icons and where? I can put them in, but I won't make them.
 
Hmm...
My Idea was:

Name Lv
[Small Potion Icon]Hp [Small Magicthingy Icon]Sp

with the name above HP and LV over SP
Don't worry, I'll do the icons myself.
Actually I think I'll post them here so others can use them.

My main concern with the HUD was being as small as possible, and being able to turn it on and off.
Thanks
 
Well, I gave up on the icons. No one wanted to do them.
But other than that, yeah. Thanks.
Have fun using this script ppl.
I don't know if Oblivion wants credit or not.
After he says whether or not he does, this thread can be closed.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top