l0rdph0enix
Member
Hey I'm trying to get this script to work for me but it keeps throwing up errors. I don't know anything bout scripting but I tried modifing two scripts I found. The end product is this,
As you can sorta see, I'm trying to get it to simply show a variable in a window that's controled by a switch [2]. Where if the switch is on the window shows and if the switch is off the window doesn't show. Instead of a number being shown thou i'd like it to show a pic in the window from the Pictures folder. The variable is controlled by a common event so that it can't be over 100 and if it is 0 you start to loose hp's. I know I can get the displaying of pics in a common event but it lags a bit and the event starts all over with each map change. i.e. Health is at 50% and player moves to a different map so hp becomes 100% again for the new map. Besides I'm trying to build a User Interface bit by bit with scripts so that it's not just a *png file. Thanks in advance for the help.
EDIT: Oh and once I've got it working, I'll gladly post it in the script resources as a Hunger System/Life System with instructions on how to set it up.
Code:
#==============================================================================
# Hunger_Hud
#------------------------------------------------------------------------------
# By: L0rdPh0enix
# 5/4/2008
#------------------------------------------------------------------------------
#==============================================================================
class Hunger_Hud < Window_Base
HUD_SWITCH = 2
Variablehunger = 22
#--------------------------------------------------------------------------
# * Initialize
#--------------------------------------------------------------------------
def initialize
super(0, 0, 200, 70)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 150
self.visible = false
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
reset_variables
self.contents.draw_text(0, 0, 100, 32, "Hunger:", 0)
if $game_switches[2] = true
self.contents.draw_text(120, 0, 32, 32, @variablehunger.to_s, 0)
end
end
def reset_variables
@variableone = $game_variables[VariableOne]
end
#==============================================================================
# ** Scene_Map
#==============================================================================
class Scene_Map
alias hungerhud_main main
alias hungerhud_update update
def main
@hungerhud = Hunger_Hud.new
hungerhud_main
@hungerhud.dispose
end
end
def update
@hud.visible = $game_switches[HUD_SWITCH]
end
@hungerhud.update
hungerhud_update
end
end
As you can sorta see, I'm trying to get it to simply show a variable in a window that's controled by a switch [2]. Where if the switch is on the window shows and if the switch is off the window doesn't show. Instead of a number being shown thou i'd like it to show a pic in the window from the Pictures folder. The variable is controlled by a common event so that it can't be over 100 and if it is 0 you start to loose hp's. I know I can get the displaying of pics in a common event but it lags a bit and the event starts all over with each map change. i.e. Health is at 50% and player moves to a different map so hp becomes 100% again for the new map. Besides I'm trying to build a User Interface bit by bit with scripts so that it's not just a *png file. Thanks in advance for the help.
EDIT: Oh and once I've got it working, I'll gladly post it in the script resources as a Hunger System/Life System with instructions on how to set it up.