Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # XS - Variable Hud
- # Author: Nicke
- # Created: 02/04/2011
- # Edited: 02/04/2012
- # Version: 1.0
- #==============================================================================
- # Instructions
- # -----------------------------------------------------------------------------
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
- #
- # A small hud to display variables on the map.
- #
- # *** Only for RPG Maker VX Ace. ***
- #==============================================================================
- ($imported ||= {})["XAIL-SIMPLE-GOLD-HUD"] = true
- module XAIL
- module VAR_HUD
- #--------------------------------------------------------------------------#
- # * Settings
- #--------------------------------------------------------------------------#
- # FONT = [name, size, color, bold, shadow]
- FONT = [["Verdana"], 14, Color.new(255,255,255), true, true]
- # HUD = [width, x, y, opacity, skin]
- HUD = [160, 405, -5, 200, 0, nil]
- # VAR_HUD_SWITCH = switch_id
- VAR_HUD_SWITCH = 10
- # VAR_LIST = [variable_id, vocab (can be nil), icon_index, x, y]
- VAR_LIST = [] # Don't remove!
- VAR_LIST[0] = [1, "Herbs", 200]
- VAR_LIST[1] = [2, "Gems", 358]
- VAR_LIST[1] = [3, "Gold", 361]
- VAR_LIST[2] = [4, nil, 359]
- VAR_LIST[3] = [5, nil, 366]
- # The space beetween the variables.
- # SPACING = number
- SPACING = 24
- end
- end
- # *** Don't edit below unless you know what you are doing. ***
- #==============================================================================#
- # ** Window_Variables
- #------------------------------------------------------------------------------
- # Class for drawing the variable hud.
- #==============================================================================#
- class Window_Variables < Window_Base
- def initialize
- # // Method to initialize the gold window.
- super(0, 0, window_width, fitting_height(XAIL::VAR_HUD::VAR_LIST.size))
- refresh
- end
- def window_width
- # // Method to return the width.
- return XAIL::VAR_HUD::HUD[0]
- end
- def draw_var(var, unit, x, y, width)
- # // Method to draw a variable with the content.
- cx = text_size(unit).width
- value = "#{$game_variables[var]}x"
- contents.font = Font.new(XAIL::VAR_HUD::FONT[0], XAIL::VAR_HUD::FONT[1])
- contents.font.color = XAIL::VAR_HUD::FONT[2]
- contents.font.bold = XAIL::VAR_HUD::FONT[3]
- contents.font.shadow = XAIL::VAR_HUD::FONT[4]
- draw_text(x, y, width - cx - 10, line_height, value, 2)
- draw_text(x, y, width - 18, line_height, unit, 2)
- reset_font_settings
- end
- def refresh
- # // Method to refresh the gold.
- contents.clear
- draw_var_hud
- end
- def draw_var_hud
- # // Method to draw the var hud.
- y = 0
- @vars = {}
- for i in XAIL::VAR_HUD::VAR_LIST
- if i[1].nil?
- draw_var(i[0], nil, -18, y, contents.width - 8)
- else
- draw_var(i[0], i[1], -10, y, contents.width - 8)
- end
- draw_icon(i[2], 100, y)
- y += XAIL::VAR_HUD::SPACING
- @vars[i[0]] = $game_variables[i[0]]
- end
- end
- def update
- # // Method to update the gold.
- super
- for i in XAIL::VAR_HUD::VAR_LIST
- refresh() if($game_variables[i[0]] != @vars[i[0]])
- end
- end
- end
- #==============================================================================
- # ** Scene_Map
- #------------------------------------------------------------------------------
- # Show variable hud on the map.
- #==============================================================================
- class Scene_Map < Scene_Base
- alias xail_var_hud_window_start start
- def start(*args, &block)
- # // Method to start the var hud window on the map.
- xail_var_hud_window_start(*args, &block)
- create_var_hud_window
- @var_hud_window.visible = $game_switches[XAIL::VAR_HUD::VAR_HUD_SWITCH]
- end
- alias xail_var_hud_window_terminate terminate
- def terminate(*args, &block)
- # // Method to terminate the var hud window on the map.
- xail_var_hud_window_terminate(*args, &block)
- dispose_var_hud_window
- end
- def create_var_hud_window
- # // Method to create the variable window.
- @var_hud_window = Window_Variables.new
- @var_hud_window.x = XAIL::VAR_HUD::HUD[1]
- @var_hud_window.y = XAIL::VAR_HUD::HUD[2]
- @var_hud_window.z = XAIL::VAR_HUD::HUD[3]
- @var_hud_window.opacity = XAIL::VAR_HUD::HUD[4]
- @var_hud_window.windowskin = Cache.system(XAIL::VAR_HUD::HUD[5]) unless XAIL::VAR_HUD::HUD[5].nil?
- end
- def dispose_var_hud_window
- # // Method to dispose the var hud window.
- @var_hud_window.dispose unless @var_hud_window.nil?
- @var_hud_window = nil
- end
- alias xail_var_hud_window_update update
- def update(*args, &block)
- # // Method to update the gold window on the map.
- xail_var_hud_window_update(*args, &block)
- @var_hud_window.update
- @var_hud_window.visible = $game_switches[XAIL::VAR_HUD::VAR_HUD_SWITCH]
- end
- end # END OF FILE
- #=*==========================================================================*=#
- # ** END OF FILE
- #=*==========================================================================*=#
Advertisement
Add Comment
Please, Sign In to add comment