Group: Member
Posts: 94
Type: Musician
RM Skill: Skilled
Hey there! I am new to scripting and have thus taken a liking to the scripting tutorial thread on this site. I was using the tutorial provided by Ccoa here --> Adding A Window to A Scene, and editing it so that it could function as a battle HUD.
As of now, everything works perfectly fine: The game starts, when the switch turns on, the window appears showing the specified iconery, it is the correct size, blah blah blah, but it doesn't show the player's HP or MP. The area of code I think that I believe I need to edit is this:
If it is, I do not know what to put there, and if it isn't, I have no unearthly clue what is wrong. I tried replacing the text (assuming it may be too low or positioned incorrectly), but that didn't work. It just doesn't show up.
Here is the entire script, and I attached the icon pngs you will need to import into your game to allow the icons to show to this thread.
# This will make sure tis isn't visible all the time. (It should only be # Viewed when in a battle self.visible = false
#Make the windonw semi-transparent (In battle it won't be, but at least #I know what method to use when needing to change the opacity self.opacity = 225
# Display actor data (In the game, I may let player switch btw characters) @actor = $data_actors[1] #Get hp of that actor @hp = @actor_hp #Get mp of the actor @mp = @actor_mp
refresh end
#remember to clear the contents of the window (basically, define refresh) def refresh self.contents.clear
# This isn't necessary, BUT, you can draw the HP icon. bitmap = Cache.load_bitmap("Graphics/Icon/", "HP") self.contents.blt(0,4, bitmap, Rect.new(0,0,24,24),255)
#draw the actual HP of the actor (I want a gauge here soon) self.contents.draw_text(0, 32, 96, 32, @hp.to_s)
#draw the icon for mp on the window (255 is the opacity!) bitmap = Cache.load_bitmap("Graphics/Icon/", "MP") self.contents.blt(0,36, bitmap, Rect.new(0,0,24,24),255)
#draw the MP of the actor self.contents.draw_text(32, 32, 96, 32, @mp.to_s) end
#run each and every frame def update
# The HUD will be visible only if this switch is on. self.visible = $game_switches[1]
#Don't update if we can't see the window if !self.visible return end
#only reresh if something has changed <-- IMPORTANT if (@hp != @actor_hp) or (@mp != @actor_hp) # current hp of actor @hp = @actor_hp #current mp of actor @mp = @actor_mp
refresh end #this allows the parent windows to do what needs to be done. (i.e #window base and whatnot) super end end
In your graphics folder, title a new folder "Icon", and stick these two in there. Make sure their files names are capitalized like this -> HP and MP.
Thank you in advance for helping me!
This post has been edited by m4uesviecr: Jul 8 2012, 07:48 AM
Attached File(s)
HP.png ( 852bytes )
Number of downloads: 0 MP.png ( 330bytes )
Number of downloads: 0