Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[Filled] HUD that displays a variable needed.

I've been thinking about it, and I could use a HUD in my ability grid.  It'd have to be specific, though, so I'll explain what a need.

*I need a display to appear on specific maps.
*I need it to display a variable based on what map the player's on. 
EX: I'm on map 1, so I need it to display variable 9.  However, on map 4, I want to display variable 3.
*The display can be simple, Current AP: \V[ID], which is what I'm currently displaying on each individual tile of the grid with event commands.

I have a demo here so you can get a better idea of what I need.  Thanks for your help!

~Guardian1239
 
Tell me if i'm totally lost here, but you want to, for example, display "Ralphs" current AP on his ability grid, and "Ylvas" current AP on her ability grid, right?
I've written a little something something for you :wink:
I've tried to be as clear as possible in the comments so that you can understand how to set it all up.
If something is unclear, just tell me and i'll try to explain better!  Anyways, here is the script:
Code:
#==============================================================================
# ** Hud_AP
#------------------------------------------------------------------------------
# By: Gando
# 12/4 2008
#------------------------------------------------------------------------------
#  This class creates the window and writes the current "AP".
#  You can customize all the "Grid.." ID's and "Variable.." variables
#  so they suit you. here are some instructions:
#
#  Grid_One   - The ID of the first Ability Grid.
#  Grid_Two   - The ID of the second Ability Grid.
#  Grid_Three - The ID of the third Ability Grid.
#  Grid_Four  - The ID of the fourth Ability Grid.
#
#  Set all the "Grid.." variables to the ID's of your four Ability Grid map's.
#  
#
#  VariableOne   - The id of the variable for "Grid_One".
#  VariableTwo   - The id of the variable for "Grid_Two".
#  VariableThree - The id of the variable for "Grid_Three".
#  VariableFour  - The id of the variable for "Grid_Four".
#
#  Example: When the player is on the "Grid_One"'s map ID, it will show the
#           "VariableOne"'s value, and when the player is on "Grid_Two"'s
#           map ID, it will show the "VariableTwo"'s value.
#
#==============================================================================
class Hud_AP < Window_Base
  # The map ID's of the Ability Grids.
  Grid_One = 1
  Grid_Two = 2
  Grid_Three = 3
  Grid_Four = 4
  
  VariableOne = 1
  VariableTwo = 2
  VariableThree = 3
  VariableFour = 4
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  # Self.opacity - This is the opacity of the window, you can change this
  #                to whatever you want between 0-255. 
  #                0 = Fully transparent 
  #                255 = opaque                             
  # 
  # Self.visible - This will make the window invisible as default. 
  #                So that the HUD won't show on every map.
  #               
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 200, 70)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 150
    self.visible = false
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  #  This will display the "Current AP:" text, and the variables of the 
  #  Party members based on which map the player is on. 
  #  You can change the "Current AP" text to whatever you want,
  #  but the rest you should keep as it is.
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    reset_variables
    self.contents.draw_text(0, 0, 100, 32, "Current AP:", 0)
  if $game_map.map_id == Grid_One
    self.contents.draw_text(120, 0, 32, 32, @variableone.to_s, 0)
  else if $game_map.map_id == Grid_Two
    self.contents.draw_text(120, 0, 32, 32, @variabletwo.to_s, 0)
  else if $game_map.map_id == Grid_Three
    self.contents.draw_text(120, 0, 32, 32, @variablethree.to_s, 0)
  else if $game_map.map_id == Grid_Four
    self.contents.draw_text(120, 0, 32, 32, @variablefour.to_s, 0)
  end
  end
  end
  end
  end
  def reset_variables
   @variableone = $game_variables[VariableOne]
   @variabletwo = $game_variables[VariableTwo]
   @variablethree = $game_variables[VariableThree]
   @variablefour = $game_variables[VariableFour]
  end
  def update
    super
    refresh if (@variableone = $game_variables[VariableOne] or
                @variabletwo = $game_variables[VariableTwo] or
                @variablethree = $game_variables[VariableThree] or
                @variablefour = $game_variables[VariableFour])
  end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This will add the HUD in Scene_Map.
#
#  Grid_One   - The ID of the first Ability Grid.
#  Grid_Two   - The ID of the second Ability Grid.
#  Grid_Three - The ID of the third Ability Grid.
#  Grid_Four  - The ID of the fourth Ability Grid.
#
#  NOTE: the numbers in these variables "Grid_One", "Grid_Two", etc. 
#        Should be the same as the ones in the beginning of this script.
#
#
#  This will make the HUD visible whenever the player is in any of the four
#  "Grid.." map ID's.
#
#==============================================================================
class Scene_Map
  # The map ID's of the Ability Grids.
  Grid_One = 1
  Grid_Two = 2
  Grid_Three = 3
  Grid_Four = 4
  alias yourhud_main main
  alias yourhud_update update
  def main
    @yourhud = Hud_AP.new
    yourhud_main
    @yourhud.dispose
  end
  def update
    if ($game_map.map_id == Grid_One or 
        $game_map.map_id == Grid_Two or 
        $game_map.map_id == Grid_Three or 
        $game_map.map_id == Grid_Four)
      @yourhud.visible = true
    else
      @yourhud.visible = false      
    end
    @yourhud.update
    yourhud_update
  end
end

Btw, you should probably turn the "Actor.." switch off when the character leaves the ability grid.
I hope it's what you're looking for! :thumb:

Over and out - Gando

EDIT:  I've updated the script so that the HUD will only show on certain maps. The hud will also display different variables depending on which map it's on. This is totally without any switches this time! :thumb:
 
This is very good, but there are two things that I'll need changed.

1. I'm now using a menu command that was made by Dargor to teleport to the ability grids, so I can't turn on switches with it.  I haven't released it in the tutorial yet because I'm still working on getting everything together.  I really need it to correspond to map IDs.

2. Also, I'm using summoning in my game, so the party members don't stay in the same order.

From looking over the menu script, I noticed something that might be useful here.

Code:
  # The Ability Grid map id
  # SYNTAX: actor_id => map_id
  Maps = {
          1 => 30, 
          4 => 33
         }
  # The initial position on the Ability Grid map id
  # SYNTAX: actor_id => [x,y]
  Position = {
              1 => [1,1],
              4 => [1,1]
             }

If the same basic setup could be used, I think that'd work.  Actor ID => Map ID and Actor ID => Variable ID might be possible, but I'm not a scripter, so I'm not really sure how things work.  Thanks for helping.

~Guardian1239
 
I should really thank you for this!
Thanks to you i improved my scripting skillz. :thumb:

I've updated the script. Now, it will only show the HUD when the player is on certain maps.
The hud will also display the values of different variables depending on which map the player is on. 
I've also updated the comments in the script so that you can understand how to set it up and customize which maps you want to display the HUD on and which variables you want to display.
And the best of all: No more switches!!

I belive that this is what you asked for. If not, tell me and i'll change it for you. :thumb:

Over and out - Gando
 
Awesome!  Thank you!  This should be just about the last thing for the VX version of my ability grid.  Now I've just got to finish the XP demo, which will take forever.  Oh well, it's all worth it.

~Guardian1239
 
Yep!  This works for both. :thumb:  I sometimes wonder why they changed the scripting for VX.  It would be a  lot easier if they just kept it he same.  Of course, I've been wondering that and why they don't include a side view battle option.  Anyway, thanks for your help.  Now I just have to fix some passability issues with my tileset and I'll be finished.

~Guardian1239
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top