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.

Variable display in main menu

hi,
so i was looking around an couldnt find this, but to a good scripter it should be easy.

all i want is a script that creats either a small window above Gold of in a new sub menu (that i can change the name of) that can show a variable.
i want to be able to set the ID of the varible (its 20, if you wanna know) and add text next to it(that say Quest points:).

thanks in advance to anyone who does it, credit will be given in my game.
 
There ya go.
Code:
#==============================================================================
# ** Quest Points Window
#------------------------------------------------------------------------------
#  © Dargor, 2008
#  Requested by jonny chleevas 
#  28/08/08
#==============================================================================

#==============================================================================
# ** Quest Window Configuration Module
#==============================================================================

module Quest_Window
  X = 0
  Y = 0
  Width = 128
  Height = 56
  Text = 'Quest Points:'
  Variable_ID = 20
end

#==============================================================================
# ** Window_QuestPoints
#------------------------------------------------------------------------------
#  This window displays quest points on the menu screen.
#==============================================================================

class Window_QuestPoints < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : window X coordinate
  #     y : window Y coordinate
  #--------------------------------------------------------------------------
  def initialize
    super(Quest_Window::X, Quest_Window::Y, Quest_Window::Width, Quest_Window::Height)
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    width = contents.text_size(Quest_Window::Text).width
    self.contents.font.color = system_color
    self.contents.draw_text(4,0,width,WLH,Quest_Window::Text)
    self.contents.font.color = normal_color
    self.contents.draw_text(4,0,width,WLH,$game_variables[Quest_Window::Variable_ID].to_s, 2)
  end
end

#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
#  This class performs the menu screen processing.
#==============================================================================

class Scene_Menu < Scene_Base
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias dargor_vx_qw_menu_start start
  alias dargor_vx_qw_menu_terminate terminate
  #--------------------------------------------------------------------------
  # * Start Processing 
  #--------------------------------------------------------------------------
  def start
    dargor_vx_qw_menu_start
    @quest_window = Window_QuestPoints.new
  end
  #--------------------------------------------------------------------------
  # * Terminate Processing
  #--------------------------------------------------------------------------
  def terminate
    dargor_vx_qw_menu_terminate
    @quest_window.dispose
  end
end

All you need to do is customize the windows settings in the Quest_WIndow module at the beginning of the script.
I didn't had the time to test the script because I'm at work so tell me if there's something wrong with it.

Take care!
-Dargor
 

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