Basic HUD Tutorial

Great tutorial. Now if I only understood Ruby..... Oh well, there is a time to learn for everything. Thanks anyway, this tutorial should come in handy for the future.
Hi, I was triying to make a HUD but I get some errors..
this is my script:

class Scene_Map
  alias Window_Status_main main
  alias Window_Status_update update
  def main
    #When I try @Window_Status = Window_Window_Status.new in the next line it doesn't
    #work either.
    @Window_Status = Window_Status.new
    Window_Status_main
    @Window_Status.dispose
  end
  def update
    @Window_Status.update
    Window_Status_update
  end
end
Expand to see the code.


and the window:

class Window_Status < Window_Base
 
  def initialize(actor)
    super(0, 0, 320, 240)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $fontface
    self.contents.font.size = $fontsize
    self.back_opacity = 145
    @actor = actor
    refresh
  end

  def refresh
    self.contents.clear
    draw_actor_graphic(@actor, 40, 80)
    draw_actor_name(@actor, 4, 0)


    draw_actor_parameter(@actor, 4, 20, 0)
    draw_actor_parameter(@actor, 4, 40, 1)
    draw_actor_parameter(@actor, 4, 60, 2)
    draw_actor_parameter(@actor, 4, 80, 3)
    draw_actor_parameter(@actor, 4, 100, 4)
    draw_actor_parameter(@actor, 4, 120, 5)
    draw_actor_parameter(@actor, 4, 140, 6)
    self.contents.font.color = system_color
    self.contents.draw_text(320, 48, 80, 32, "")
    self.contents.draw_text(320, 80, 80, 32, "")
    self.contents.font.color = normal_color
  end

end
Expand to see the code.


When I go to this Window by the Menu (the ESCAPE menu*) It works.

Can someone tell me what I'm doing wrong?
[QUOTE=DeadCaL;136009]Hello, I've tried this various ways. I've tried the exact one in the original post. I've tried the 'initialize' update, and I've tried removing @yourhud.dispose

I still get

Script 'HUD' line 3: RGSSError occoured.

disposed window


What else should I be lookin out for? I'm not great with scripting, what can be up with line 3?[/QUOTE]
it might be a bit old but change:
@yourhud.dispose
Expand to see the code.

to
@yourhud.dispose if [email protected]?
Expand to see the code.

to fix the disposed window error
Can you help me with my hud..?

I'm trying to make it so my hero's sprite is displayed next to his hp/sp, but I have no clue how. Also if you can, explain to me how I replace my window with a picture...

Script Spoiler
class Window_YourHUD < Window_Base
  def initialize
    super(0, 0, 350, 60)
self.contents = Bitmap.new(width - 32, height - 32)
self.back_opacity = 160
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if !@actor
    draw_actor_hp(@actor, 2, 2)
    draw_actor_sp(@actor, 170,2)
  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
Expand to see the code.
where do i put the hud code?
@_@ i could alittle help, this my 3rd day of working with Rpg maker xp. i been trying to make a window base of hud system that well show the level of a set skill like fishing. problem is when the skill goes the hud does not update. stays at 0, And yes i read all the "basic hub" example tutorial and i do see the "update" part but dont understand it nor how to make it with variables and not actors.

ill show you what i have so far:

class Window_YourHUD < Window_Base
#----------------------------------------------------------------------
# * Object Initialization
#----------------------------------------------------------------------
def initialize
super(0, 416, 640, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh # Calls the refresh function in this class
end

def refresh
self.contents.clear
self.contents.font.color = normal_color
self.contents.font.size = 20
self.contents.draw_text(65, 5, 100, 32, $game_variables[1].to_s)
self.contents.draw_text(5, 5, 100, 32, "Fishing" )
end

end

class Scene_Map
alias yourhud_main main
def main
@yourhud = Window_YourHUD.new
refresh
@refresh.dispose
end
end
Just set an instance variable to the game variable on a refresh, and check that instance variable to the main one each update. Something like this:
class Fishing_HUD < Window_Base
  def initialize
    super(0, 416, 640, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.size = 20
    refresh
  end
  def refresh
    self.contents.clear
    @fishing_var = $game_variables[1]
    self.contents.draw_text(65, 5, 100, 32, @fishing_var.to_s)
    self.contents.draw_text(5, 5, 100, 32, 'Fishing')
  end
  def update
    super
    refresh if @fishing_var != $game_variables[1]
  end
end
class Scene_Map
  alias fishing_hud_main main
  alias finishg_hud_update
  def main
    @fishing_hud = Fishing_HUD.new
    fishing_hud_main
    @fishing_hud.dispose
  end
  def update
    @fishing_hud.update
    fishing_hud_update
  end
end
Expand to see the code.
thanks alot,but theres some kind of problem on line 22? and iam noob and need help
line 22 is def main in the class Scene_Map
i tryed playing around to cross search over hud systems, i have no clue why this aint working
Some one can please give me the finished HUD script without the EXP bar?
TNX anyway :)
Swordhunter, there is no finished HUD. This is a tutorial on HOW to make a basic one.
Bagginhard, sorry about the small error. A little mistake on my part. Replace this line:
alias finishg_hud_update
Expand to see the code.
With this:
alias finishg_hud_update update
Expand to see the code.
thanks. wow yea i should have seen that mistake.
now iam gettin a line 29 error plus you seems to know alot could you tell me how do i get a npc to say the actor custom name?
hello?
For the actor's name put this in the message:

\n[1]

...and it will show the name.
thanks, thats work gread now if i could get Yeyinde to talk to me,
Bagginhard;169170 wrote:
iam gettin a line 29 error

A little more information would be helpful. Just telling me what line number the error occurs on will not solve the problem. Tell me the exact error code (screenshot it) and the text on the error line, then I can fix the error.
the error is undefined method.
the problem is just a typo:
alias finishg_hud_update update
Expand to see the code.
he put finishg instead of fishing.
wow, iam smart your right toriverly. i need looking at this for a almost a week now and didnt see that typo. what would i do without yall. thanks again.

is there a easy way to line the word "fishing" (line 13) to line up with the games variable ($game_variables[1]). also is there away to make it appear and disappear on a button command?

now iam going to try to make it show more then just fishing skill. could you tell me show to make a screen shot.
Hi all,

How can i make a game screen just like this one?



http://i205.photobucket.com/albums/bb11 ... k/dink.jpg[/img]


(I mean the grey window alrond the screen (see the red arrows)

thx

House 
I'm getting
Script 'hud_window' line 30: SyntaxError occured. guess what. tats

line 30: end
I know its a tad too late to be posting something like this. Still, can you guys please stop littering Yeyinde's tut thread with RGSS (Script Requests/Support) questions? Post those into the appropriate sections. Thanks.

RGSS Support - I need help with something.
RGSS Script Request - I need something.

@danpantry : You have too many "end"s. You probably pasted it and left an extra end. But I'd need to see the script as you have it, to be certain. Create a thread over in RGSS Support if you're still interested.
I am using rmvx.
I followed your tutorial just like you said..

But when i finished i did not know what to do??

Do you just click apply and ok and then test play??

or do you have to save it or do something else?
what do i put for the x y coordinates for

draw_actor_hp(actor, x , y )
draw_actor_sp(actor, x , y )


?????????????????????????????????????????????????????//
i have no clue waht to put for the x, y and idk what those are?
Its the xy locationon the screen in pixels from the upper left hand corner
you know like the IV grid quadrent except that its +,+ and not +,-
ya i got it.
thank ya ! (L)
EDIT:

Oops. I should have just put it past the 'last' end of the HUD script. :P
--------------------------------------------------------------------------------------
Sorry if it's necroposting but I did it successfully eons ago and am returning to RPGMaker XP... and kinda stymied by this issue. Alrighty. Here's my code for this HUD. (as directed) -- but for some reason I keep hitting an

Quote:
Script 'Window_YourHUD' line 31: NameError occurred.

undefined method 'main' for class "Window_YourHUD::Scene_Map"


And this is in the same script as my HUD script below everything and before the last 'end'

(would the 'end' bit be causing this?)

Quote:
class Scene_Map
(line31) 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
~Hey this has been dead for quite some time. Next time look at the date and make sure not to necropost.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=9404