08-20-2008, 01:00 PM
Timer Rewrite
Introduction
This script allows you to turn your timer display on/off, it allows you to change the opacity of the timer, it allows you to used fixed positioning e.g. Top Left, Bottom Right etc and it also allows you to set an exact position on the screen for it to appear along with being able to change your font size and type for the timer.
To use the visibility switch, just change the number in the [] to the number of your timer switch:-
As for the position, just call script and call one of the following, dependant on where you want to place it:-
For an exact position you must call this code:-
Remember to replace the #'s for real numbers.
Replace the '#' with the opacity you want it to be, 255 being solid, 0 being invisible.
Replace the # and "font here" to what size and font type you want it to be.
Script
Add this script above Main.
Credits
Kurisu aka Slipper for helping me point out my mistake
This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given. If you are the owner of the thread, please contact administration.
No support is given. If you are the owner of the thread, please contact administration.
Introduction
This script allows you to turn your timer display on/off, it allows you to change the opacity of the timer, it allows you to used fixed positioning e.g. Top Left, Bottom Right etc and it also allows you to set an exact position on the screen for it to appear along with being able to change your font size and type for the timer.
TIMER DISPLAY SWITCH
To use the visibility switch, just change the number in the [] to the number of your timer switch:-
Code:
$game_switches[numberhere] == false
FIXED POSITIONING
As for the position, just call script and call one of the following, dependant on where you want to place it:-
Code:
#TOP LEFT
$game_system.timer_position = 0
Code:
#TOP RIGHT
$game_system.timer_position = 1
Code:
#BOTTOM LEFT
$game_system.timer_position = 2
Code:
#BOTTOM RIGHT
$game_system.timer_position = 3
UNIVERSAL POSITIONING
For an exact position you must call this code:-
Code:
$game_system.timer_position = 4
$game_system.timer_posx = #
$game_system.timer_posy = #
Remember to replace the #'s for real numbers.
OPACITY CONTROL
Replace the '#' with the opacity you want it to be, 255 being solid, 0 being invisible.
Code:
$game_system.timer_opacity = #
CHANGE FONT SIZE & TYPE
Replace the # and "font here" to what size and font type you want it to be.
Code:
$game_system.timer_fontsize = #
$game_system.timer_fontsize = "fonthere"
Script
Add this script above Main.
"Script"
Code:
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles system-related data. Also manages vehicles and BGM, etc.
# The instance of this class is referenced by $game_system.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :timer # timer
attr_accessor :timer_working # timer working flag
attr_accessor :timer_position # timer screen position
attr_accessor :timer_posx # timer position x axis
attr_accessor :timer_posy # timer position y axis
attr_accessor :timer_opacity # timer opacity
attr_accessor :timer_fonttype # timer font type
attr_accessor :timer_fontsize # timer font size
attr_accessor :save_disabled # save forbidden
attr_accessor :menu_disabled # menu forbidden
attr_accessor :encounter_disabled # encounter forbidden
attr_accessor :save_count # save count
attr_accessor :version_id # game version ID
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@timer = 0
@timer_working = false
@timer_position = 1
@timer_opacity = 255
@timer_posx = 0
@timer_posy = 0
@timer_fonttype = "Arial"
@timer_fontsize = 32
@save_disabled = false
@menu_disabled = false
@encounter_disabled = false
@save_count = 0
@version_id = 0
end
#--------------------------------------------------------------------------
# * Get Battle BGM
#--------------------------------------------------------------------------
def battle_bgm
if @battle_bgm == nil
return $data_system.battle_bgm
else
return @battle_bgm
end
end
#--------------------------------------------------------------------------
# * Set Battle BGM
# battle_bgm : new battle BGM
#--------------------------------------------------------------------------
def battle_bgm=(battle_bgm)
@battle_bgm = battle_bgm
end
#--------------------------------------------------------------------------
# * Get Battle End ME
#--------------------------------------------------------------------------
def battle_end_me
if @battle_end_me == nil
return $data_system.battle_end_me
else
return @battle_end_me
end
end
#--------------------------------------------------------------------------
# * Set Battle End ME
# battle_end_me : new battle end ME
#--------------------------------------------------------------------------
def battle_end_me=(battle_end_me)
@battle_end_me = battle_end_me
end
#--------------------------------------------------------------------------
# * Get Position of Timer
#--------------------------------------------------------------------------
def timer_position
return @timer_position
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if @timer_working and @timer > 0
@timer -= 1
if @timer == 0 and $game_temp.in_battle # If the timer 0 in battle
$game_temp.next_scene = "map" # interrupt the battle
end
end
end
end
#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
# This sprite is used to display the timer. It observes the $game_system
# and automatically changes sprite conditions.
#==============================================================================
class Sprite_Timer < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
# viewport : viewport
#--------------------------------------------------------------------------
def initialize(viewport)
super(viewport)
self.bitmap = Bitmap.new(88, 48)
self.bitmap.font.name = $game_system.timer_fonttype
self.bitmap.font.size = $game_system.timer_fontsize
@timer_position = $game_system.timer_position
self.x = 544
self.y = 0
self.z = 200
update
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
case @timer_position
when 0 # Top Left
self.x = 85 - self.bitmap.width
self.y = 0
when 1 # Top Right
self.x = 544 - self.bitmap.width
self.y = 0
when 2 # Bottom Left
self.x = 85 - self.bitmap.width
self.y = 370
when 3 # Bottom Right
self.x = 544 - self.bitmap.width
self.y = 370
when 4 # Custom
self.x = $game_system.timer_posx
self.y = $game_system.timer_posy
end
super
self.visible = $game_system.timer_working
self.bitmap.font.name = $game_system.timer_fonttype
self.bitmap.font.size = $game_system.timer_fontsize
if $game_switches[1] == false
self.opacity = $game_system.timer_opacity
else
self.opacity = 0
end
if $game_system.timer / Graphics.frame_rate != @total_sec
self.bitmap.clear
@timer_position = $game_system.timer_position
@total_sec = $game_system.timer / Graphics.frame_rate
min = @total_sec / 60
sec = @total_sec % 60
text = sprintf("%02d:%02d", min, sec)
self.bitmap.font.color.set(255, 255, 255)
self.bitmap.draw_text(self.bitmap.rect, text, 1)
end
end
end
Credits
Kurisu aka Slipper for helping me point out my mistake