Personally, I fail at scripting. So I thought I'd come to y'all to see if you guys can do what I can't (which is very likely, I can't do next to anything with scripting).
Anyway, here's what I'm trying to do. For my game, I want to have a window that's constantly on-screen. It'd be small, compact, and tucked away in the upper-right corner. All that would be in it is an HP display, like so (Pardon the horrible drawing):
-------------------
| HP: XXX/XXX |
| xxxxxxxxxxxxx |
-------------------
Basically? I want an HP count above and the bar graphic below, one that will reflect my current HP, if at all possible. Thanks for your time.
Is it OK to have some overlap or do they have to be completely disjoint?
It's fine to have some overlap, like in the menu.
You have friends in heart places.
If there is anything you want changed or if something doesn't work, just post and I will try to fix it.
#==============================================================================
# Zeichwolf HUD
# Version: 1.0
# Author: modern algebra
# Date: February 15, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Description:
# A simple HUD that just shows the HP of the lead actor.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Instructions:
# Paste this script above Main and below Materials in the Script Editor (F11)
#
# To toggle the HUD on and off, you can use the call script:
# toggle_hud (x)
#
# where x is either true or false, where true means the HUD will be shown
# and false means it won't be. If you do not give any argument, it will just
# toggle the visibility of the HUD, i.e. turn it on if it is off and off it
# is on.
#==============================================================================
#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased method - hp=
#==============================================================================
class Game_Actor
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Change HP
# hp : new HP
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias modalg_zeichwof_hudsply_hpequals_64b6 hp=
def hp=(hp)
# Run Original Method
modalg_zeichwof_hudsply_hpequals_64b6 (hp)
# If HUD showing self and scene is map
$scene.refresh_zhud if $game_party.members[0] == self && $scene.is_a? (Scene_Map)
end
end
#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new instance variable - zhud_visible
# aliased method - initialize
#==============================================================================
class Game_System
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Public Instance Variables
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
attr_accessor :zhud_visible # Boolean determining whether to show HUD or not
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_zeichwolf_init_simp_hud_85h6 initialize
def initialize
# Run Original Method
malg_zeichwolf_init_simp_hud_85h6
# Initialize new variable
@zhud_visible = true
end
end
#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# new method - toggle_hud
#==============================================================================
class Game_Interpreter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Toggle HUD
# boolean : if desired, set directly to a value
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def toggle_hud (boolean = nil)
$game_system.zhud_visible = boolean == nil ? !$game_system.zhud_visible : boolean
$scene.refresh_zhud if $scene.is_a? (Scene_Map)
end
end
#==============================================================================
# ** Window_ZHUD
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# This window shows a simply HP display
#==============================================================================
class Window_ZHUD < Window_Base
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Object Initialization
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def initialize
# Run Super method
super (384, 0, 160, 32 + WLH)
self.opacity = 160
refresh
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh
self.contents.clear
# Set visibility
self.visible = $game_system.zhud_visible
# Do not draw anything if no actors are in the party
return if $game_party.members.size < 1
# Draw HP of lead party member
draw_actor_hp ($game_party.members[0], 0, 0, 128)
end
end
#==============================================================================
# ** Scene Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Summary of Changes:
# aliased methods - start, terminate
# new methods - refresh_ZHUD
#==============================================================================
class Scene_Map
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Start
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias mornbra_zeic_hud_strt_6w52d start
def start
# Run Original Method
mornbra_zeic_hud_strt_6w52d
# Create ZHUD window
@zhud_window = Window_ZHUD.new
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Terminate
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias malg_zechwlf_hedsupdply_trmnte_1hb5 terminate
def terminate
# Dispose of HUD window
@zhud_window.dispose
# Run Original Method
malg_zechwlf_hedsupdply_trmnte_1hb5
end
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# * Refresh ZHUD
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def refresh_zhud
return if @zhud_window.disposed? || @zhud_window == nil
@zhud_window.refresh
end
end
I kind of actually posted this yesterday by editing my first post, but I just realized today that you had posted before then so you probably never saw it so I am posting it again.
Heh, yeah. Zylos actually got me into the whole thing, so it's convenient that he happened to be a higher-up too!
But anyway, I stuck the script in, tested it out, everything's working just fine. It's really nicely done, thanks!
...And I'm gonna hate myself for this, but I'm gonna be picky for just a moment. Any way you can make the window say "HP" instead of just "H"? n.n;
Just change it in the database (F9). The last tab is the Terms tab and one of the entries is HP (abbr.): - change that to HP
Ah, thanks again, I'm still a bit new, so I make mistakes like this. ;D