[RMVX] DISPLAYING A VARIABLE ON SCREEN

Posts

Pages: 1
I'm using a script Liberty gave me to display the value of a variable on the screen. I just want to know how to change the font of the number displayed.

Here is the script:

#===============================================================================
# Variable Window Snippet
# By Jet10985
# Help by: Piejamas, BigEd781, Mithran
#===============================================================================
# This snippet will allow you to show 1 variable in a window at the top-right
# of the screen. Edited by Liberty. XP
#===============================================================================



module VarWindow

VAR_NAME_1 = "Score:" # The name for the 1st variable shown. You can change it
#to anything you want, but keep the name inside the quotation marks or it won't
#work.


VARIABLE_1 = 1 # Variable shown for VAR_NAME_1


ALLOW_TRIGGER = false # Let the player hide the window by pressing a button? if
#you do want for the player to be able to toggle the score on/off then set this
#to true instead.

HIDE_WINDOW_BUTTON = Input::CTRL # If true, what button? You can change what
#button you want to use to toggle the score to be hidden.


SWITCH_TO_SHOW = 5 # This is the switch that needs to be on to show the window.
#Just change the number to match the corresponding switch.

OPACITY = 0 # This is how transperant the window is. 0 is fully transperant.
#If you want it partly transparent try about 160 or so. 250 is fully opaque.


end

#===============================================================================
# DON'T EDIT FURTHER UNLESS YOU KNOW WHAT TO DO.
#===============================================================================
class Window_Variable < Window_Base

include VarWindow
#the line with the numbers are the positions. Number 1 is X (across),
#number 2 is Y (up/down). The other two mess with the box itself, the first
#beign width and the next being height.
def initialize
super(400, 0, 145, 60)
self.opacity = OPACITY
self.visible = false
refresh
end

def refresh
self.contents.clear
self.contents.draw_text(0, 0, 222, WLH, VAR_NAME_1 + " " + @var_one.to_s)
end

def update
if @var_one != $game_variables[VARIABLE_1] |
@var_one = $game_variables[VARIABLE_1]
refresh
end
end
end

class Scene_Map

include VarWindow

alias jet5830_start start unless $@
def start
jet5830_start
@var_window = Window_Variable.new
@var_1 = $game_variables[VARIABLE_1]
@first_switch = false
end

alias jet5839_update update unless $@
def update
jet5839_update
@var_window.update
variable_update
end

alias jet5299_terminate terminate unless $@
def terminate
@var_window.dispose
jet5299_terminate
end

def variable_update
if @first_switch == false and $game_switches[SWITCH_TO_SHOW]
@var_window.visible = true
@first_switch = true
end
if Input.trigger?(HIDE_WINDOW_BUTTON) && ALLOW_TRIGGER && $game_switches[SWITCH_TO_SHOW]
@var_window.visible = !@var_window.visible
end
end
end
I like the \v method myself.
author=ShortStar
I like the \v method myself.
Me too, I'm so old school LOL.
Add self.contents.font.name = "fontname" in def refresh.


author=Bandito
author=ShortStar
I like the \v method myself.
Me too, I'm so old school LOL.

How do you old schoolers display a variable when walking?
KingArthur
( ̄▽ ̄)ノ De-facto operator of the unofficial RMN IRC channel.
1217
author=heisenman
Add self.contents.font.name = "fontname" in def refresh.
Specifically:
  def refresh
self.contents.clear
self.contents.font.name = ["Font"]
self.contents.draw_text(0, 0, 222, WLH, VAR_NAME_1 + " " + @var_one.to_s)
end
You can also add font.size (integer), font.bold (true/false), font.italic (true/false), font.shadow (true/false), and font.color (RGB+Alpha value) before draw_text to further modify the text drawn.

As a side note, you can set multiple fonts in font.name, like so:
self.contents.font.name = ["Verdana", "Arial", "Courier New"]
and RMVX will use the fonts from left to right, moving to the next one if the first one isn't found (if "Verdana" wasn't found, it'll try "Arial", and so forth).

author=heisenman
author=Bandito
author=ShortStar
I like the \v method myself.
Me too, I'm so old school LOL.
How do you old schoolers display a variable when walking?
Pictures in Parallel Events (usually Common Event ones).
^ Said x10 times better lol.

Also, thanks.
Works perfectly, thanks!
Pages: 1