Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- =begin
- ==============================================================================
- ■ Holy87's Menu Variables
- version 1.0
- User difficulty: ★
- License: CC-BY. Everyone can distribute this script and use in their free
- and commercial games. Credit required.
- ==============================================================================
- This script adds so many variables you like in the main menu, inside the
- gold window, to add more currencies
- ==============================================================================
- ■ Compatibility
- Window_Gold -> alias refresh
- ==============================================================================
- ■ Installation and instructions
- Place this script under Materials and above Main.
- Configure how many variables you want int the VARIABLES array below.
- ==============================================================================
- =end
- #==============================================================================
- # ** CONFIGURATION
- #------------------------------------------------------------------------------
- # Script configuration
- #==============================================================================
- module MenuVariablesConfig
- VARIABLES = [
- #--------------------------------------------------------------------------
- # * Add so many lines as the variables you want to shoq, like the example:
- #--------------------------------------------------------------------------
- #Name Variable ID icon (0 to none)
- ["Crystals", 1, 343 ],
- ["Emblems", 2, 245 ],
- ["Stardusts", 3, 348 ],
- ]#do not remove the parenthesys!
- end
- #==============================================================================
- # ** Variable_Description
- #------------------------------------------------------------------------------
- # Contains informations of the variable to show
- #==============================================================================
- class Variable_Description
- attr_reader :name #name
- attr_reader :id #variable ID
- attr_reader :icon_index #icon index
- #--------------------------------------------------------------------------
- # * Initialization
- # var_array: array for variable informations [name, id, icon]
- #--------------------------------------------------------------------------
- def initialize(var_array)
- @name = var_array[0]
- @id = var_array[1]
- @icon_index = var_array[2]
- end
- #--------------------------------------------------------------------------
- # * Returns the variable value
- #--------------------------------------------------------------------------
- def value; $game_variables[@id]; end
- #--------------------------------------------------------------------------
- # * Returns true if it hasn't the icon
- #--------------------------------------------------------------------------
- def no_icon?; @icon_index == 0 || @icon_index.nil?; end
- end
- #==============================================================================
- # ** Window_Gold
- #------------------------------------------------------------------------------
- # Edit the window to include the variables
- #==============================================================================
- class Window_Gold < Window_Base
- include MenuVariablesConfig #module inclusion
- alias h87_menuvariable_refresh refresh unless $@
- #--------------------------------------------------------------------------
- # * Method for height
- #--------------------------------------------------------------------------
- def fitting_height(number)
- number += VARIABLES.size if SceneManager.scene.is_a?(Scene_Menu)
- super(number)
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- if SceneManager.scene.is_a?(Scene_Menu)
- contents.clear
- draw_variables
- draw_currency_value(value, currency_unit, 4, line_height*@variables.size, contents.width - 8)
- else
- h87_menuvariable_refresh
- end
- end
- #--------------------------------------------------------------------------
- # * Obtains the variable informations
- #--------------------------------------------------------------------------
- def get_variables
- @variables = []
- for i in 0.. VARIABLES.size-1
- @variables.push(Variable_Description.new(VARIABLES[i]))
- end
- end
- #--------------------------------------------------------------------------
- # * Draw the variables
- #--------------------------------------------------------------------------
- def draw_variables
- get_variables
- for i in 0..@variables.size-1
- var = @variables[i]
- twidth = contents_width - text_size(var.value).width
- twidth -= 24 unless var.no_icon?
- change_color(system_color)
- draw_text(0, line_height*i, twidth, line_height, var.name)
- change_color(normal_color)
- twidth = contents_width - (var.no_icon? ? 0 : 24)
- draw_text(0, line_height*i, twidth, line_height, var.value, 2)
- unless var.no_icon?
- draw_icon(var.icon_index, contents_width-24, line_height*i)
- end
- end
- end
- end #end of the script.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement