RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
(RESOLVED) [XP] Extremely simple hud fix needed

0 Members and 4 Guests are viewing this topic.

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
So the game I've been working on won't have very many battles, but will have several environmental ways of dealing damage. I then came to the conclusion that the player should be able to see his/her HP at all times, so they don't have to constantly hit Esc to see their health after they've been hurt.
I decided I'd find a super simple HUD to display just their HP, which I DID find (http://www.gdunlimited.net/forums/topic/3598-your-very-own-hud/) and was very happy with. Unfortunately, It shows no matter what the player is doing, which is especially difficult to deal with during cutscenes. 

So, All I need are these few fixes:

1. Some way to turn off the HUD for periods of time, preferably with a switch of some sort so I can easily cut it out of certain scenes.

2. The removal of the arrow at the end of the HUD, I have no idea why that's there.

That's all I really need. I normally can figure these things out, despite my utter lack of programming and scripting knowledge, but so far I've only been able to figure out how to put the window where I want it to be.

Original Script:
Spoiler for:
Code: [Select]
class Window_YourHUD < Window_Base
  def initialize
    super(0, 0, 640, 64)
    self.opacity = 150
    self.contents = Bitmap.new(640 - 32, 64 - 32)
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if !@actor
    draw_actor_hp(@actor, 0, 0)
    draw_actor_sp(@actor, 300, 0)
    draw_actor_exp(@actor, 500, 0)
  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

Same Script, but edited to my settings:
Spoiler for:
Code: [Select]
class Window_YourHUD < Window_Base
  def initialize
    super(7, 410, 200, 64)
    self.opacity = 150
    self.contents = Bitmap.new(640 - 32, 64 - 32)
    refresh
  end
  def refresh
    self.contents.clear
    reset_variables
    return if !@actor
    draw_actor_hp(@actor, 20, 0)
  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
« Last Edit: November 11, 2013, 01:12:11 AM by UltimaZix »
Good things are good by design.

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
Good things are good by design.

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
Lump da BUMP
Good things are good by design.

***
Rep:
Level 70
RMRK Junior
I'll try taking a crack at this later tonight when I have more time.  But fixing is actually a relatively simple task.  Add a new "Option" to your Game System with an alias.  Then to turn the HUD on or off, use a Script: $game_system.my_option = true / false.  In the Update method, just use it to hide but not remove the HUD.

Code: [Select]
class Game_System

  attr_accessor :my_new_property # allow $game_system.my_new_property = value in Script

  alias my_custom_initialize initialize
  def initialize
    # Run Original Initialize or any other Aliases of Initialize
    my_custom_initialize
    # New Property
    @my_new_property = true
  end
end

class My_Custom_Hud
  def update
    if $game_system.my_option
      @opacity = 255 # Or @object.opacity = 255
    else
      @opacity = 0    # or @object.opacity = 0
    end
    # Rest of update code
  end
end

---

Edit

Got it.  You were very close.  Just add "attr_accessor :yourhud" to Scene_Map and you can use an Event Script to set opacity and contents_opacity to 0 for your scene.

$scene.yourhud.opacity = 0
$scene.yourhud.contents_opacity = 0

Not sure about that White Arrow pointing right...
« Last Edit: November 09, 2013, 09:21:00 AM by Heretic86 »
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

*
RMRK's dad
Rep:
Level 86
You know, I think its all gonna be okay.
For going the distance for a balanced breakfast.Project of the Month winner for June 2009For being a noted contributor to the RMRK Wiki2013 Best WriterSilver Writing ReviewerSecret Santa 2013 Participant
Bumpity
Lump da BUMP

No malice, but that kind of thing typically gets you nowhere or worse around here. Just sayin'.
:tinysmile:

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
I'll try taking a crack at this later tonight when I have more time.  But fixing is actually a relatively simple task.  Add a new "Option" to your Game System with an alias.  Then to turn the HUD on or off, use a Script: $game_system.my_option = true / false.  In the Update method, just use it to hide but not remove the HUD.

Code: [Select]
class Game_System

  attr_accessor :my_new_property # allow $game_system.my_new_property = value in Script

  alias my_custom_initialize initialize
  def initialize
    # Run Original Initialize or any other Aliases of Initialize
    my_custom_initialize
    # New Property
    @my_new_property = true
  end
end

class My_Custom_Hud
  def update
    if $game_system.my_option
      @opacity = 255 # Or @object.opacity = 255
    else
      @opacity = 0    # or @object.opacity = 0
    end
    # Rest of update code
  end
end

---

Edit

Got it.  You were very close.  Just add "attr_accessor :yourhud" to Scene_Map and you can use an Event Script to set opacity and contents_opacity to 0 for your scene.

$scene.yourhud.opacity = 0
$scene.yourhud.contents_opacity = 0

Not sure about that White Arrow pointing right...

First of all, you are an extremely beautiful human being for putting all that effort into this silly menial problem of mine. For that, you have my eternal gratitude.
Secondly, I'll test it out right now and see if it works, thanks again!

EDIT - GOOD GRAVY, IT WORKS! Also, I did some testing with that dagnabbed arrow, and I think it's an issue with window_base. Whenever I make the window not show all the text, or make it slightly smaller, the arrow appears. I'll try editing your_hud and the window_base to see what I can do to erase it.

EDIT 2 - Got rid of the arrow!!! I just lowered how much space was left for content in the box, and it went away! Thanks again for all your help man, consider yourself credited in my game! What name/alias shall I list you as?


Bumpity
Lump da BUMP

No malice, but that kind of thing typically gets you nowhere or worse around here. Just sayin'.

Ah, I see. Thought I read somewhere that bumping was allowed, so I figured I'd try it. Thanks for lettin' me know, I'll refrain from doing so.
« Last Edit: November 10, 2013, 11:19:40 PM by UltimaZix »
Good things are good by design.

***
Rep:
Level 70
RMRK Junior
Glad we could help.

Bump notes:  Generally one is allowed after at least 24 hours.  Three posts in 5 minutes with no other replies without eding is usually what most moderators and admins get frustrated about.
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
Glad we could help.

Bump notes:  Generally one is allowed after at least 24 hours.  Three posts in 5 minutes with no other replies without eding is usually what most moderators and admins get frustrated about.

Ahhh, I gotcha. I'll keep bampin' to a minimum then. Other than that, thanks again! What name or title do ya want to be credited as in the game?
Good things are good by design.

***
Rep:
Level 70
RMRK Junior
Typically Heretic86 or Heretic, either works fine for me.
Heretic's Vehicles XP (Boat and Magic Carpet)

Heretic's Collection XP Ver 2.3 - Updated to include Dynamic Lighting, Moving Platforms, Vehicles, and much much more!

**
Rep:
Level 40
Team Rye Creator
For the great victory in the Breakfast War.
Typically Heretic86 or Heretic, either works fine for me.

You got it dood, thanks a bundle c: Screenshots for the game will be up soon too, I'll shoot ya a message when they're ready
Good things are good by design.