AbyssalLord
Member
Ok, I have made a HUD that is supposed to display certain variables/gold based on which switches are active. I've got it working all except for one thing that I can't figure out. Whenever I activate the HUD (using switch 1), a blank window appears. So far so good (since the other switches are not on yet). Now, the issue is what happens with all of the other switches. When I turn on switch 2 (for example), the text does not appear. Only once I open the menu (or otherwise navigate away from that map) and then return to the map is the text there. I would appreciate any help you could give.
Here's the code:
Here's the code:
Code:
class Window_GoldHUD < Window_Base
def initialize
super(440,0,200,60)
self.contents = Bitmap.new(width - 32, height - 32)
self.opacity = 255
refresh
end
def refresh
self.contents.clear
reset_gold
if $game_switches[2] == true
self.contents.clear
self.contents.draw_text(-60, 0, 150, 32, $game_party.gold.to_s, 2)
self.contents.draw_text(100, 0, 150, 32, "Gold")
elsif $game_switches[3] == true
self.contents.draw_text(-60, 0, 150, 32, @bank_gold.to_s, 2)
self.contents.draw_text(100, 0, 150, 32, "Gold")
elsif $game_switches[4] == true
self.contents.draw_text(-60, 0, 150, 32, @loan_gold.to_s, 2)
self.contents.draw_text(100, 0, 150, 32, "Owed")
end
end
def reset_gold
@gold = $game_party.gold
@bank_gold = $game_variables[1] #Change the [1] to whatever variable ID you want
# to use to display the gold in the bank.
@loan_gold = $game_variables[6]#Change the [6] to whatever variable ID you want
#to use to display the gold you owe the bank(loans).
end #You must do the same below for this to work.
def update
super()
refresh if ( @gold != $game_party.gold or
@bank_gold != $game_variables[1] or #If you changed the ID's above, you must
@loan_gold != $game_variables[6] ) #change them to the same ID's here.
end
end
class Scene_Map
alias goldhud_main main
alias goldhud_update update
def main
@goldhud = Window_GoldHUD.new
@goldhud.visible = $game_switches[1] #Change this ID to change the switch that
goldhud_main #makes the HUD appear.
@goldhud.dispose
end
def update
@goldhud.visible = $game_switches[1] #Same as above.
@goldhud.update
goldhud_update
end
end