#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
# ** Glitchfinder's Multiple Timers [RPG Maker XP] [RPG Maker VX]
# Version 3.33
#------------------------------------------------------------------------------
# This script helps scripters and eventers use multiple hidden in-game timers
# that can be called and modified at any time.
#==============================================================================
# * Version History
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Version 1.00 ------------------------------------------------- (??????????)
# - Initial version
# - Author: Glitchfinder
# Version 2.00 ------------------------------------------------- (2008-06-11)
# - Script completely rewritten to work with multiple timers
# - Author: Glitchfinder
# Version 2.10 ------------------------------------------------ (2002-06-18)
# - Added the check_timing() method
# - Fixed bug with check() method
# - Author: Glitchfinder
# Version 2.11 ----------------------------------------------- (2007-06-19)
# - Reformatted and cleaned script
# - Author: Glitchfinder
# Version 2.21 ------------------------------------------------ (2007-06-22)
# - Added the extended_start() method
# - Author: Glitchfinder
# Version 2.31 ------------------------------------------------ (2007-07-20)
# - Added the update_single() method
# - Added the kill_timer() method
# - Added the adjust_time() method
# - Author: Glitchfinder
# Version 2.32 ----------------------------------------------- (2007-07-24)
# - Fixed bug with VX and the start() method
# - Fixed bug with VX and the extended_start() method
# - Author: Glitchfinder
# Version 3.32 ------------------------------------------------- (2009-06-28)
# - Script completely rewritten to increase efficiency
# - Modified most methods to include error-checking
# - Renamed the check() method to finished?()
# - Removed the modifications of Game_Temp
# - Added the script to the global variable $game_timer
# - Added new output to the check_timing() method
# - Modified the update() method of Scene_Battle
# - Added the ability for a timer to end battle
# - Added the end_battle() method
# - Added the end_battle?() method
# - Modified the update() method of Sprite_Timer
# - Added the ability to display a timer using Sprite_Timer
# - Modified the "Conditional Branch..." event command
# - Modified the "Control Variables..." event command
# - Modified the "Control Timer..." event command
# - Replaced the default timer with $game_timer
# - Added the display() method
# - Added the display?() method
# - Modified the write_save_data() method of Scene_Save
# - Modified the read_save_data() method of Scene_Load
# - Added the ability to save a timer when the game is saved
# - Added the save() method
# - Added the save?() method
# - Added the load_save() method
# - Author: Glitchfinder
# Version 3.33 ----------------------------------------------- (2009-06-28)
# - Script optimized further
# - Unnecessary lines removed
# - Code efficiency improved
# - Author: theory
#==============================================================================
# * Instructions
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Place this script above Main, and below the default scripts. (I realize this
# is obvious to most, but some people don't get it.)
#
# To start a timer, use the following call:
# $game_timer.start(seconds, key)
# Where seconds is the number of seconds you want the timer to run, and
# key is the name of that specific timer. You must use a seperate name for
# every timer, because when one finishes, only the first script checking for
# that name will return with the timer completed.
#
# To start an extended timer, use the following call:
# $game_timer.extended_start(hours, minutes, seconds, key)
# Where hours, minutes, and seconds are the number of hours, minutes, and
# seconds you wish the timer to run. key follows the same rules as it
# does in the method above.
#
# To check whether or not a timer has finished, use the following call:
# $game_timer.finished?(key)
# Where timer_number is the number of the timer that you need to check. See
# the rules above regarding key.
#
# To remove a timer, you use the following call:
# $game_timer.kill_timer(key)
# Where timer_number is the number of the timer you wish to stop. Please read
# the above rules regarding key.
#
# To adjust the remaining time, use the following call:
# $game_timer.adjust_time(setting, value, key)
# Where setting is what kind of operation you wish to perform. (1 for
# addition, 2 for subtraction, 3 for multiplication, and 4 for division) Value
# must be the number of seconds you wish to add or subtract, or the number you
# wish to add or divide by. Finally, timer_number is the number of the timer
# you wish to edit. (Once again, see above for rules regarding key)
#
# To update a single timer seperately, you must use the following call:
# $game_timer.update_single(key)
# Where key is the number of the timer you wish to update. This is meant to be
# used to update specific timers in scenes that this script doesn't normally
# update in. (In other words, anything other than Scene_Map)
# It can also be used to update a specific timer at a rate that is faster than
# normal, when variable speeds are necessary.
#
# For debugging purposes, check the timer with the following call:
# $game_timer.check_timing(key)
# Where key is the number of the timer you are checking. (once again, see
# above for details on key) It will either display the remaining frames before
# the timer is finished, or it will tell you that the timer has finished. If
# the timer does not exist, it will print a message to inform you of that
# fact.
#
# To stop or start a timer, use the following call:
# $game_timer.active(key, bool)
# Where key is the timer you want to start or stop, and bool is true if you
# want to start the timer, and false if you want to stop it.
#
# To have a timer force battles to abort when they reach zero, use the
# following call:
# $game_timer.end_battle(key, bool)
# Where key is the timer you want to modify, and bool is true if you want it
# to abort battles while it is 0, and false if you don't.
#
# To set a timer to display, use the following call:
# $game_timer.display(key, bool)
# Where key is the timer you want to display, and bool is either true or
# false, depending on the desired result.
#
# To set a timer to be saved in the save file, use the following call:
# $game_timer.save(key, bool)
# Where key is the timer you want to have saved, and bool is true if you want
# the timer to be saved, and false if you want it to disappear when the game
# is closed.
#==============================================================================
# * Glitchfinder's Advice
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script is meant for people with a medium to high level of scripting
# knowledge and ability. If you are unsure of your abilities, or don't know
# how to script, then it would be a good idea to avoid this script.
#
# This script has been tested in both script and events, and will function in
# both cases.
#==============================================================================
# * Contact
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# Glitchfinder, the author of this script, may be contacted through his
# website, found at http://www.glitchkey.com
#
# You may also find Glitchfinder at http://www.hbgames.org
#==============================================================================
# * Usage
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# This script may be used with the following terms and conditions:
#
# 1. This script is free to use in any noncommercial project. If you wish to
# use this script in a commercial (paid) project, please contact
# Glitchfinder at his website.
# 2. This script may only be hosted at the following domains:
# http://www.glitchkey.com
# http://www.hbgames.org
# 3. If you wish to host this script elsewhere, please contact Glitchfinder.
# 4. If you wish to translate this script, please contact Glitchfinder. He
# will need the web address that you plan to host the script at, as well
# as the language this script is being translated to.
# 5. This header must remain intact at all times.
# 6. Glitchfinder remains the sole owner of this code. He may modify or
# revoke this license at any time, for any reason.
# 7. Any code derived from code within this script is owned by Glitchfinder,
# and you must have his permission to publish, host, or distribute his
# code.
# 8. This license applies to all code derived from the code within this
# script.
# 9. If you use this script within your project, you must include visible
# credit to Glitchfinder and theory, within reason.
#≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡
#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
# This sprite is used to display the timer.It observes the $game_system
# class and automatically changes sprite conditions.
#==============================================================================
class Sprite_Timer < Sprite
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Hide timer sprite and return if there is no currently displayed timer
self.visible = $game_timer.display? == false ? false : true
return if self.visible == false
# If timer needs to be redrawn
if $game_timer.display? / Graphics.frame_rate != @total_sec
# Calculate total number of seconds and make a string
@total_sec = $game_timer.display? / Graphics.frame_rate
text = sprintf("%02d:%02d", @total_sec / 60, @total_sec % 60)
# Clear window contents and draw timer
self.bitmap.clear
self.bitmap.draw_text(self.bitmap.rect, text, 1)
end
end
end
#----------------------------------------------------------------------------
# * Check for RGSS1
#----------------------------------------------------------------------------
unless (defined?(RGSS1p5) == true || defined?(Graphics.brightness) == true)
#==============================================================================
# ** Scene_Save
#------------------------------------------------------------------------------
# This class performs save screen processing.
#==============================================================================
class Scene_Save < Scene_File
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_scene_save_write_save_data write_save_data
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
scriptastic_timer_scene_save_write_save_data(file)
Marshal.dump($game_timer.save?, file)
end
end
#==============================================================================
# ** Scene_Load
#------------------------------------------------------------------------------
# This class performs load screen processing.
#==============================================================================
class Scene_Load < Scene_File
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_scene_load_read_save_data read_save_data
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
scriptastic_timer_scene_load_read_save_data(file)
$game_timer.load_save(Marshal.load(file)) unless file.eof?
end
end
#----------------------------------------------------------------------------
# * End Check for RGSS1
#----------------------------------------------------------------------------
end
#----------------------------------------------------------------------------
# * Check for RGSS1 or RGSS1.5
#----------------------------------------------------------------------------
if (defined?(RGSS1p5) == true || defined?(Graphics.brightness) != true)
#==============================================================================
# ** Interpreter
#------------------------------------------------------------------------------
# This interpreter runs event commands. This class is used within the
# Game_System class and the Game_Event class.
#==============================================================================
class Interpreter
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_interpreter_command_111 command_111
alias scriptastic_timer_interpreter_command_122 command_122
#--------------------------------------------------------------------------
# * Conditional Branch
#--------------------------------------------------------------------------
def command_111
# Initialize local variable: result
result = false
# If checking timer
if @parameters[0] == 3
# Call modified method
result = $game_timer.conditional_branch(@parameters)
# Skip if branch is false
return command_skip if result == false
end
# Store determinant results in hash
@branch[@list[@index].indent] = result
# If determinant results are true
if @branch[@list[@index].indent] == true
# Delete branch data
@branch.delete(@list[@index].indent)
# Continue
return true
end
# Call aliased method
scriptastic_timer_interpreter_command_111
end
#--------------------------------------------------------------------------
# * Control Variables
#--------------------------------------------------------------------------
def command_122
# Initialize value
value = 0
# If @parameters[3] is set to other
if @parameters[3] == 7
# If @parameters[4] is set to timer
if @parameters[4] == 5 # timer
# Call modified method
$game_timer.control_variables(@parameters)
# Continue
return true
end
end
# Call aliased method
scriptastic_timer_interpreter_command_122
end
#--------------------------------------------------------------------------
# * Control Timer
#--------------------------------------------------------------------------
def command_124
# Call modified method
$game_timer.control_timer(@parameters)
# Continue
return true
end
end
#----------------------------------------------------------------------------
# * End Check for RGSS1 or RGSS1.5
#----------------------------------------------------------------------------
end
#----------------------------------------------------------------------------
# * Check for RGSS2 or RGSS1.5
#----------------------------------------------------------------------------
if (defined?(RGSS1p5) == true || defined?(Graphics.brightness) == true)
#==============================================================================
# ** Scene_File
#------------------------------------------------------------------------------
# This class performs the save and load screen processing.
#==============================================================================
class Scene_File < Scene_Base
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_scene_file_write_save_data write_save_data
alias scriptastic_timer_scene_file_read_save_data read_save_data
#--------------------------------------------------------------------------
# * Write Save Data
# file : write file object (opened)
#--------------------------------------------------------------------------
def write_save_data(file)
scriptastic_timer_scene_file_write_save_data(file)
Marshal.dump($game_timer.save?, file)
end
#--------------------------------------------------------------------------
# * Read Save Data
# file : file object for reading (opened)
#--------------------------------------------------------------------------
def read_save_data(file)
scriptastic_timer_scene_file_read_save_data(file)
$game_timer.load_save(Marshal.load(file)) unless file.eof?
end
end
#----------------------------------------------------------------------------
# * End Check for RGSS2 or RGSS1.5
#----------------------------------------------------------------------------
end
#----------------------------------------------------------------------------
# * Check for RGSS2
#----------------------------------------------------------------------------
if (defined?(RGSS1p5) != true && defined?(Graphics.brightness) == true)
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_game_interpreter_command_111 command_111
alias scriptastic_timer_game_interpreter_command_122 command_122
#--------------------------------------------------------------------------
# * Conditional Branch
#--------------------------------------------------------------------------
def command_111
# Initialize local variable: result
result = false
# If checking timer
if @params[0] == 3
# Call modified method
result = $game_timer.conditional_branch(@params)
# Skip if branch is false
return command_skip if reult == false
end
# Store determinant results in hash
@branch[@indent] = result
# If determinant results are true
if @branch[@indent] == true
# Delete branch data
@branch.delete(@indent)
# Continue
return true
end
# Call aliased method
scriptastic_timer_game_interpreter_command_111
end
#--------------------------------------------------------------------------
# * Control Variables
#--------------------------------------------------------------------------
def command_122
# Initialize value
value = 0
# If @params[3] is set to other
if @params[3] == 7
# If @params[4] is set to timer
if @params[4] == 5 # timer
# Call modified method
$game_timer.control_variables(@params)
# Continue
return true
end
end
# Call aliased method
scriptastic_timer_game_interpreter_command_122
end
#--------------------------------------------------------------------------
# * Control Timer
#--------------------------------------------------------------------------
def command_124
# Call modified method
$game_timer.control_timer(@params)
# Continue
return true
end
end
#----------------------------------------------------------------------------
# * End Check for RGSS2
#----------------------------------------------------------------------------
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_scene_map_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
scriptastic_timer_scene_map_update
$game_timer.update
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias scriptastic_timer_scene_battle_update update
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
$game_timer.update
$game_temp.battle_abort = true if $game_timer.end_battle?
scriptastic_timer_scene_battle_update
end
end
#==============================================================================
# ** Game_Timer
#------------------------------------------------------------------------------
# This class performs processing for in-script timers.
# Refer to "$game_temp.game_timer" for the instance of this class.
#==============================================================================
class Game_Timer
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Create timer hash
@timers = {}
# Set timer hash defaults
@timers.default = {'time' => 0, 'active' => false, 'display' => false,
'endbattle' => false, 'finished' => false,
'save' => false}
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@timers.keys.each { |key|
# Skip if the current timer is inactive, otherwise deduct timer
@timers[key]['active'] == false ? next : @timers[key]['time'] -= 1
# Set the timer to finished if the frame count is 0 or less
@timers[key]['active'] = false and
@timers[key]['finished'] = true if @timers[key]['time'] <= 0}
end
#--------------------------------------------------------------------------
# * Frame Update (individual timer)
# key : key for specific timer
#--------------------------------------------------------------------------
def update_single(key)
# Return if the current timer is inactive, otherwise deduct timer
@timers[key]['active'] == false ? return : @timers[key]['time'] -= 1
# Set the timer to finished if the frame count is 0 or less
if @timers[key]['time'] <= 0
@timers[key]['active'] = false
@timers[key]['finished'] = true
end
end
#--------------------------------------------------------------------------
# * Start Timer
# seconds : time, in seconds
# key : key for specific timer
#--------------------------------------------------------------------------
def start(seconds, key)
# Check the validity of the second value
unless seconds.is_a?(Integer)
# Print an error and exit if the second value is invalid
p "You must set a timer's remaining time to a numeric value"
exit
end
# Setup new timer
@timers[key] = {'time' => seconds * Graphics.frame_rate, 'active' => true,
'display' => false, 'endbattle' => false,
'finished' => false, 'save' => false}
end
#--------------------------------------------------------------------------
# * Start Timer (extended)
# hours : added hours (not including minutes or seconds)
# minutes : added minutes (not including hours or seconds)
# seconds : added seconds (not including hours or minutes)
# key : key for specific timer
#--------------------------------------------------------------------------
def extended_start(hours, minutes, seconds, key)
# Check the validity of the time value
unless (hours.is_a?(Integer) == true && minutes.is_a?(Integer) == true &&
seconds.is_a?(Integer) == true)
# Print an error and exit if the time value is invalid
p "You must set a timer's remaining time to a numeric value"
exit
end
# Calculate time
time = ((hours * 3600 * Graphics.frame_rate) +
(minutes * 60 * Graphics.frame_rate) +
(seconds * Graphics.frame_rate))
# Setup new timer
@timers[key] = {'time' => time, 'active' => true, 'display' => false,
'endbattle' => false, 'finished' => false, 'save' => false}
end
#--------------------------------------------------------------------------
# * Check Timer
# key : key for specific timer
#--------------------------------------------------------------------------
def finished?(key)
# Return false if the timer has not finished
return false if @timers[key]['finished'] == false
# Delete timer
@timers.delete(key)
return true
end
#--------------------------------------------------------------------------
# * Check Timer (Debugging)
# key : key for specific timer
#--------------------------------------------------------------------------
def check_timing(key)
return unless ($DEBUG == true || $TEST == true)
# If the Timers hash includes the key
if @timers.include?(key)
# If the timer has time remaining
if @timers[key]['finished'] == false
# Set up message and print
s = 'The timer named ' + key.to_s + ' has ' + @timers[key]['time'].to_s
s += ' frames remaining.'
p s
else
# Print message
p 'The timer named ' + key.to_s + ' has reached zero.'
end
# Print message if timer is inactive
if @timers[key]['active'] == false
p 'The timer named ' + key.to_s + ' is currently inactive.'
end
# Print message if timer is set to end battle
if @timers[key]['endbattle'] == true
p 'The timer named ' + key.to_s + ' is currently set to end battle.'
end
# print message if timer is set to be saved in the file
if @timers[key]['save'] == true
p 'The timer named ' + key.to_s + ' is currently saved with the game.'
end
else
# Print message
p 'The timer named ' + key.to_s + ' does not exist.'
end
end
#--------------------------------------------------------------------------
# * Kill Timer
# key : key for specific timer
#--------------------------------------------------------------------------
def kill_timer(key)
# Return if the timer does not exist
return unless @timers.include?(key)
# Delete the timer
@timers.delete(key)
end
#--------------------------------------------------------------------------
# * Adjust Remaining Time
# setting : type of operation
# value : value to use in the operation
# key : key for specific timer
#--------------------------------------------------------------------------
def adjust_time(setting, value, key)
# Print an error and exit if the value is invalid
unless value.is_a?(Integer)
p "You must modify a timer's remaining time with a numeric value"
exit
end
# Print an error and exit if the second value is invalid
unless (setting >= 1 && setting <= 5)
p "You have used an invalid setting when modifying the timer."
exit
end
case setting
when 1 then @timers[key]['time'] += value
when 2 then @timers[key]['time'] -= value
when 3 then @timers[key]['time'] *= value
when 4 then @timers[key]['time'] /= value
when 5 then @timers[key]['time'] %= value
end
end
#--------------------------------------------------------------------------
# * Set Timer's Active Boolean
# key : key for specific timer
# bool : true or false, where true ends battle when timer is at 0
#--------------------------------------------------------------------------
def active(key, bool)
# Check bool's validity
unless (bool == true || bool == false)
# Print an error and exit if bool is invalid
p "You must set a timer's active boolean to either true or false."
exit
end
# Return if the timer does not exist
return unless @timers.include?(key)
# Set timer boolean
@timers[key]['active'] == bool
end
#--------------------------------------------------------------------------
# * Timer Active?
# key : key for specific timer
#--------------------------------------------------------------------------
def active?(key)
return @timers[key]['active']
end
#--------------------------------------------------------------------------
# * Set Timer's End Battle Boolean
# key : key for specific timer
# bool : true or false, where true ends battle when timer is at 0
#--------------------------------------------------------------------------
def end_battle(key, bool)
# Check bool's validity
unless (bool == true || bool == false)
# Print an error and exit if bool is invalid
p "You must set a timer's end battle boolean to either true or false."
exit
end
# Return if the timer does not exist
return unless @timers.include?(key)
# Set timer boolean
@timers[key]['endbattle'] == bool
end
#--------------------------------------------------------------------------
# * End Battle?
#--------------------------------------------------------------------------
def end_battle?
@timers.keys.each {|key| next if @timers[key]['active'] == false
return true if @timers[key]['endbattle'] && @timers[key]['finished']}
return false
end
#--------------------------------------------------------------------------
# * Set Timer's Display Boolean
# key : key for specific timer
# bool : true or false, where true means the timer is displayed
#--------------------------------------------------------------------------
def display(key, bool)
# Check bool's validity
unless (bool == true || bool == false)
# Print an error and exit if bool is invalid
p "You must set a timer's display boolean to either true or false."
exit
end
# Return if the timer does not exist
return unless @timers.include?(key)
# Set timer boolean
@timers[key]['display'] = bool
end
#--------------------------------------------------------------------------
# * Display Timer?
#--------------------------------------------------------------------------
def display?
@timers.keys.each {|key| next if @timers[key]['active'] == false
return @timers[key]['time'] if @timers[key]['display'] == true}
return false
end
#--------------------------------------------------------------------------
# * Set Timer's Save Boolean
# key : key for specific timer
# bool : true or false, where true means the timer is displayed
#--------------------------------------------------------------------------
def save(key, bool)
# Check bool's validity
unless (bool == true || bool == false)
# Print an error and exit if bool is invalid
p "You must set a timer's save boolean to either true or false."
exit
end
# Return if the timer does not exist
return unless @timers.include?(key)
# Set timer boolean
@timers[key]['save'] = bool
end
#--------------------------------------------------------------------------
# * Save Timer?
#--------------------------------------------------------------------------
def save?
save = {}
@timers.keys.each{|x| save[x] = @timers[x] if @timers[x]['save'] == true}
return save
end
#--------------------------------------------------------------------------
# * Load Saved Timer
#--------------------------------------------------------------------------
def load_save(timers)
return if timers.empty?
timers.keys.each {|key| @timers[key] = timers[key]}
end
#--------------------------------------------------------------------------
# * Conditional Branch
#--------------------------------------------------------------------------
def conditional_branch(parameters)
# If event timer is active
if active?('event')
# Set timer variable to currently displayed timer
timer = display?
# Skip command if no timer is currently displayed
return false if timer == false
# Calculate remaining timer
sec = timer / Graphics.frame_rate
# If checking for a value <= remaining time
if parameters[2] == 0
# set result to the truth value of remaining time >= checked time
result = (sec >= parameters[1])
else
# set result to the truth value of remaining time <= checked time
result = (sec <= parameters[1])
end
else
# Skip command if timer is not active
return false
end
end
#--------------------------------------------------------------------------
# * Control Variables
#--------------------------------------------------------------------------
def control_variables(parameters)
timer = display?
timer = 0 if timer == false
value = timer / Graphics.frame_rate
# Loop for group control
for i in parameters[0] .. parameters[1]
# Branch with control
case parameters[2]
when 0 then $game_variables[i] = value
when 1 then $game_variables[i] += value
when 2 then$game_variables[i] -= value
when 3 then $game_variables[i] *= value
when 4 # divide
if value != 0
$game_variables[i] /= value
end
when 5 # remainder
if value != 0
$game_variables[i] %= value
end
end
# Max / Min limit check
$game_variables[i] = 99999999 if $game_variables[i] > 99999999
$game_variables[i] = -99999999 if $game_variables[i] < -99999999
end
# Refresh map
$game_map.need_refresh = true
end
#--------------------------------------------------------------------------
# * Control Timer
#--------------------------------------------------------------------------
def control_timer(parameters)
# If started
if parameters[0] == 0
# Start timer
$game_timer.start(parameters[1], 'event')
# Set timer to end battle
$game_timer.end_battle('event', true)
# Display timer
$game_timer.display('event', true)
# Set timer to save with game
$game_timer.save('event', true)
# If stopped
else
# Hide timer
$game_timer.active('event', false)
end
end
end
begin
$game_timer = Game_Timer.new
end