Display a Variable in the Menu

Hi, I searched around and could not find a script of this nature that did exactly what I needed it to.

Basically, I need a window on the menu with the same appearance as the gold window, that overwrites the gold window into something more.

What this window will do is, it will display, in this order:

  • Current playtime
  • Currency
  • Variable of your choice

In my game's case, I'll be using it to display the second currency, which is kept track of with a variable. That being said, the variable you pick to display can be for whatever you need it to be for. 

I also want it to show a title to represent the variable, in the style of how Gold is displayed, that you can enter to be whatever you wish. 

It would also be handy to be able to customize the y axis position of the window in case you want to do that. I don't need it to do that, but I want this script to be something other people may find useful as well and I'm sure some people would want it to do that. 

And here's a mock up of how I want it to look like: https://40.media.tumblr.com/604ffbcfe96742df92d574aab1d3ae04/tumblr_inline_npnez6qQZz1rtomod_540.png
Hey, I threw this together in a couple of minutes

Spoiler
module HopeFragmentMenu Variable_id = 3 #The variable to be shown Format = "Honor: %s" #The format of the variable, with %s replaced with #the current value of the variableendclass Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # * Create Gold Window #-------------------------------------------------------------------------- def create_gold_window @gold_window = Window_GoldExtra.new @gold_window.x = 0 @gold_window.y = Graphics.height - @gold_window.height endend#==============================================================================# ** Window_Gold#------------------------------------------------------------------------------# This window displays the party's gold.#==============================================================================class Window_GoldExtra < Window_Base #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize super(0, 0, window_width, fitting_height(3)) end #-------------------------------------------------------------------------- # * Get Window Width #-------------------------------------------------------------------------- def window_width return 160 end #-------------------------------------------------------------------------- # * Refresh #-------------------------------------------------------------------------- def update contents.clear draw_playtime(4, 0) draw_currency_value(value, currency_unit, 4, line_height, contents.width - 8) var = $game_variables[HopeFragmentMenu::Variable_id].to_s var = sprintf(HopeFragmentMenu::Format,var) draw_text_ex(4,line_height*2,var) end def draw_playtime(x,y) draw_text_ex(x, y,$game_system.playtime_s) end #-------------------------------------------------------------------------- # * Get Party Gold #-------------------------------------------------------------------------- def value $game_party.gold end #-------------------------------------------------------------------------- # Get Currency Unit #-------------------------------------------------------------------------- def currency_unit Vocab::currency_unit end #-------------------------------------------------------------------------- # * Open Window #-------------------------------------------------------------------------- def open super end def draw_currency_value(value, unit, x, y, width) cx = text_size(value.to_s).width change_color(normal_color) draw_text(x, y, width-2-cx, line_height, value, 0) change_color(system_color) draw_text(x+2+cx, y, width, line_height, unit, 0) endend
I hope it has everything you need. 

The config is at the top of the script, and looks like this:

Code:
module HopeFragmentMenu   Variable_id = 3 #The variable to be shown   Format = "Honor: %s" #The format of the variable, with %s replaced with                        #the current value of the variableend
Thank you so much, this works perfectly!

Original thread: https://forums.rpgmakerweb.com/threads/display-a-variable-in-the-menu.40982/