I don't have it embedded in a script. I have it embedded in my game. It is merged into the core scripts. The only way I'll get it out is to completely rewrite it, which I know I've done once ... I just can't find anywhere on my pc that it's saved.
Anyone have a copy of CT_Bolt's Timer Script? [Found!]
RGSS3 Script RequestsOh dang. That's totally different. Er, okay, would you be willing to recreate it for me? I can't pay, totally broke, but I'd really appreciate it.
Here you go. It's just a simple set/execute timer. There's the ability to delete it before it expires, but no check to see whether a timer is set, or how much longer it has to go.
Code:
#=============================================================================
#
# MultiTimers by Shaz
#
# Set up multiple timers with no on-screen display, to execute (by 'eval')
# a command.
#
#-----------------------------------------------------------------------------
#
# To set a timer:
# $game_timer.set_mt(unique_key, seconds, command)
#
# Examples:
# Turn on a switch after 10 seconds
# $game_timer.set_mt('TurnOnSwitch8', 10, '$game_switches[8] = true')
#
# Make the player jump in 5 seconds
# $game_timer.set_mt('PlayerJump', 5, '$game_player.jump(0,0)')
#
#-----------------------------------------------------------------------------
#
# To set a timer for a self switch:
# $game_timer.set_ss_mt(map_id, event_id, self_switch_id, seconds, value)
#
# Examples:
# Turn on a specific event's self switch 'A' in 5 seconds
# $game_timer.set_ss_mt(24, 5, 'A', 5, true)
#
# Turn on 'this' event's self switch 'A' in 5 seconds
# $game_timer.set_ss_mt(@map_id, @event_id, 'A', 5, true)
#
#-----------------------------------------------------------------------------
#
# To cancel a timer:
# $game_timer.delete_mt(key)
# $game_timer.delete_ss_mt(map_id, event_id, self_switch_id)
#
# To cancel the timers set above:
# $game_timer.delete_mt('TurnOnSwitch8')
# $game_timer.delete_mt('PlayerJump')
#
# To cancel the self switch timers set above:
# $game_timer.delete_ss_mt(24, 5, 'A')
# $game_timer.delete_ss_mt(@map_id, @event_id, 'A')
#
#=============================================================================
class Game_Timer
alias shaz_mt_initialize initialize
alias shaz_mt_update update
def initialize
shaz_mt_initialize
@multi_timer = {}
end
def update
shaz_mt_update
update_mt
end
#--------------------------------------------------------------------------
# * Set a timer
# key - unique id string
# seconds - how many seconds to wait
# command - string to eval
#--------------------------------------------------------------------------
def set_mt(key, seconds, command)
@multi_timer[key] = [Graphics.frame_count + seconds * Graphics.frame_rate, command]
end
#--------------------------------------------------------------------------
# * Set a timer for a self switch
# map, event, self switch - self switch to turn on/off
# seconds - how many seconds to wait
# value - new self switch value
#--------------------------------------------------------------------------
def set_ss_mt(map, event, selfswitch, seconds, value = true)
key = sprintf('%d %d %s', map, event, selfswitch)
command = sprintf('%s[[%d,%d,\'%s\']]=%s', '$game_self_switches', map, event,
selfswitch, value)
@multi_timer[key] = [Graphics.frame_count + seconds * Graphics.frame_rate, command]
end
#--------------------------------------------------------------------------
# * Delete a timer
# cancels a previously set timer
#--------------------------------------------------------------------------
def delete_mt(key)
@multi_timer.delete(key)
end
def delete_ss_mt(map, event, selfswitch)
key = sprintf('%d %d %s', map, event, selfswitch)
delete_mt(key)
end
#--------------------------------------------------------------------------
# * Update timers
#--------------------------------------------------------------------------
def update_mt
triggered = false
@multi_timer = {} if !@multi_timer
@multi_timer.select {|key, value| value[0] <= Graphics.frame_count}.each do |key, value|
eval(value[1])
@multi_timer.delete(key)
triggered = true
end
$game_map.need_refresh = true if triggered
end
end
Thank you so much! I'll test it right away!
I just made a couple of changes to the comments at the top. They reflected an approach that didn't work and I changed, but I only just realised I hadn't updated the comments with the correction.
Make sure the key, self switch id, and command are all strings, enclosed in single or double quotes.
Make sure the key, self switch id, and command are all strings, enclosed in single or double quotes.
Okay, so I've been needing a timer that could effect self-variables and switches for such a long time. I'm using the Self Data Suite, and I needed a timer that could change all self-variables and self-switches with certain names in the game. All of them, even ones belonging to events not on the same map. Should this be possible with the current setup, or does the script need to be modified further? I have a script person I can ask, if you don't want to do it.
You should be able to do it. Just depends how the self data suite saves & changes its values, and what "with certain names" means.
I have self-variables named things like "Examine" that get one added to when the player looks at an event using the E key. That gives a short description. In doing this, I can have consecutive unique messages for each time the player looks at it. However, I want the messages to reset after 15 minutes or so, hence the timer. I'd make all events with the self-variable "Examine" reset that variable to 0 when that time ends. The tricky part is resetting it back to 15 if the player looks at anything else.
generally you'd want to set a timer on that particular event the moment the player activates that event. So each event can have its own timer and is independent of any other event.
Probably. I'll consider the matter overnight before I decide how I'll proceed, I guess. Thanks again for the help. You get brownie points!
You know, if you want to change them all at once, I'd use the timer to turn on a single global switch after 15 minutes, then have a common event set to parallel process, conditioned by that switch. In the common event, have all the commands to reset all the self switches / self variables, then turn off the global switch at the end so it only runs once.
That means the timer is only tracking one item rather than potentially many, yet they'll all get reset at the same time.
You will probably be able to use a script call to loop through all the self switches / self variables, as long as you can figure out how to change them from an unrelated event. If you provide a link to the script it shouldn't take too much to figure out.
I'm just not sure why you want to reset them all at the same time.
That means the timer is only tracking one item rather than potentially many, yet they'll all get reset at the same time.
You will probably be able to use a script call to loop through all the self switches / self variables, as long as you can figure out how to change them from an unrelated event. If you provide a link to the script it shouldn't take too much to figure out.
I'm just not sure why you want to reset them all at the same time.
Just found this from a link in Wayback machine. @Shaz can you convert to the original CT Bolt script.
CT Bolts timer seems to have been based off Tsukihimes timer post/script
*EDIT***********************************************************************
So I found an older copy of the script from a game. It's v2.5 not 3.0
So it's missing
Code:
$game_timer.add_time(20) #add 20 seconds
$game_timer.lose_time(15) #lose 15 seconds
$game_timer.pause #pause countdown
$game_timer.resume #resume countdown
#==============================================================================
# ** Game_Timer
#------------------------------------------------------------------------------
# Some more methods
#==============================================================================
class Game_Timer
alias timer_plus_update update
def update
if !@pause
timer_plus_update
end
end
# add more time, in seconds
def add_time(count)
@count += count * Graphics.frame_rate
end
# subtract time, in seconds
def lose_time(count)
@count = [@count - (count * Graphics.frame_rate), 0].max
end
def pause
@pause = true
end
def resume
@pause = false
end
end
For graphics changes, additions will have to be made to Sprite_Timer, but I haven't decided where the best places to add the changes are.
For example, a simple change is to automatically change the color depending on the time left (red = almost 0, etc)
#==============================================================================
# ** Sprite_Timer
#------------------------------------------------------------------------------
# This sprite is for timer displays. It monitors $game_timer and automatically
# changes sprite states.
#==============================================================================
class Sprite_Timer < Sprite
alias timer_plus_sprite_update update
def update
timer_plus_sprite_update
update_color
end
def update_color
if @total_sec > 0 && @total_sec < 295
self.bitmap.font.color.set(255, 0, 0)
else
self.bitmap.font.color.set(255, 242, 132)
end
end
end
Code:
RMVXAce – CT_Bolt’s Timer
CT_Bolt’s Timer v2.21
by CT_Bolt
Features
A whole new timer.
Custom properties (font color, font size, x, y, z, etc.).
Let’s you press buttons with while a ct_timer is active.
Counts the button presses & stores them in a variable.
Allows a switch to be used to determine if the ct_timer will be visible.
Optional text before & after time numbers (ex. Timer #1: 0:25 Remaining).
Multiple buttons can be pressed.
Add\Remove time from a currently running CT_Timer with a simple script call.
Pause\Resume a currently running CT_Timer with a simple script call.
Compatibility
This should be compatible with all scripts as long as they don’t overwrite any methods used in this script.
How to Use
In a script call use the following method to start/stop a ct_timer:
ct_timer(mins, secs, start)
Examples:
ct_timer(1, 30) # Starts a timer at 1 min 30 seconds
ct_timer(0, 80) # Starts a timer at 1 min 20 seconds
ct_timer(2) # Starts a timer at 2 mins
ct_timer(0, 0, false) # Stops the timer
In a script call you can also use the following:
Examples:
$ct_game_timer.add_time (1, 20) # Add 1 minute & 20 seconds
$ct_game_timer.lose_time(0, 15) # Subtract 15 seconds
$ct_game_timer.pause # Pause countdown
$ct_game_timer.resume # Resume countdown
Configure module CT_Timer to the way you would like it.
See the script for more details.
CT Bolts timer seems to have been based off Tsukihimes timer post/script
*EDIT***********************************************************************
So I found an older copy of the script from a game. It's v2.5 not 3.0
Code:
#==============================================================================
# Title: CT_Bolt's Timer
# Author: CT_Bolt
# Date: March 03, 2013
# Version History:
# v1.00 (02-28-2013)
# -- First release
# v1.02 (03-01-2013)
# -- Bug Fix & More Comments
# v2.0 (03-01-2013)
# --Major Update
# -- Changed from a Timer Add-on to it's own timer
# v2.1 (03-03-2013)
# --Added Features
# -- Optional prefix & suffix can now be added
# -- Multiple buttons can now be assigned for pressing
# v2.2 (03-03-2013)
# --Added more features
# -- Add or remove time from a currently running CT_Timer
# -- Pause & resume a currently running CT_Timer
# v2.21 (03-08-2013)
# --Bugfix - Save/Load wasn't working
# v2.5 (07-21-2013)
# -- Added features
# --Audio was added
# -- Ability to fade in
#------------------------------------------------------------------------------
# Description:
# A whole new timer.
# Custom properties (font color, font size, x, y, z, etc.)
# Let's you press multiple buttons while a ct_timer is active.
# Counts the button presses & stores them in a variable.
# Allows a switch to be used to determine if the ct_timer will be visible.
# Add\Remove time from a currently running CT_Timer with a simple script call.
# Pause\Resume a currently running CT_Timer with a simple script call.
#------------------------------------------------------------------------------
# Compatibility:
# This should be compatible with all scripts as long as they
# don't overwrite any methods used in this script.
#
# Alias Methods:
# module DataManager
# create_game_objects
# make_save_contents
# extract_save_contents(contents)
#
# class Spriteset_Map
# initialize
# dispose
# update
#
# class Spriteset_Battle
# initialize
# dispose
# update
#
# class Scene_Map < Scene_Base
# update
#
# class Scene_Battle < Scene_Base
# def update
# def update_basic
#
#------------------------------------------------------------------------------
# Usage:
# In a script call use the following method to start/stop a ct_timer:
# ct_timer(mins, secs, start)
#
# Examples:
# ct_timer(1, 30) # Starts a timer at 1 min 30 seconds
# ct_timer(0, 80) # Starts a timer at 1 min 20 seconds
# ct_timer(2) # Starts a timer at 2 mins
# ct_timer(0, 0, false) # Stops the timer
#
# In a script call you can also use the following:
# Examples:
# $ct_game_timer.add_time (1, 20) # Add 1 minute & 20 seconds
# $ct_game_timer.lose_time(0, 15) # Subtract 15 seconds
# $ct_game_timer.pause # Pause countdown
# $ct_game_timer.resume # Resume countdown
#
# Configure module CT_Timer to the way you would like it.
#------------------------------------------------------------------------------
# Installation:
# To install the script, open the script editor and paste this script on
# a new section (insert) below the Materials & above Main Process.
#==============================================================================
#==============================================================================
# ** Module CT_Timer
#------------------------------------------------------------------------------
#==============================================================================
module CT_Timer
STAY_IN_BATTLE_SWITCH_ID = 1 # Switch used to keep the player in battle
# after the timer expires
ACCEPT_INPUT_SWITCH_ID = 2 # Switch used to determine if button input
# will be accepted
HIDE_TIMER_SWITCH_ID = 3 # Switch used to determine if the timer will
# be displayed
PAUSE_IN_BATTLE_SWITCH_ID = 7 # Switch used to determine if the timer will
# update in battle
WAIT_FOR_TIMER_SWITCH_ID = 9 # Set true to "pause the battle"
BUTTON_PRESS = [:Z, :Y] # Button symbols for what button will be used
# Default valid button symbols:
# :DOWN = Down Arrow Key
# :LEFT = Left Arrow Key
# :RIGHT = Right Arrow Key
# :UP = Up Arrow Key
# :A = Shift Key
# :B = X or Esc Key
# :C = Z or Enter or Space Key
# :X = A Key
# :Y = S Key
# :Z = D Key
# :L = Q Key
# :R = W Key
# :SHIFT = Shift Key
# :CTRL = CTRL Key
# :ALT = ALT Key
# :F5 = F5 Key
# :F6 = F6 Key
# :F7 = F7 Key
# :F8 = F8 Key
# :F9 = F9 Key
# Note if you never want to use that at all
# set it to nil (BUTTON_PRESS = nil)
BUTTON_COUNT_VAR_ID = 1 # Variable ID used to keep count of how many
# times the button was pressed
COMMON_EVENT_ID = 2 # Optional (set to nil if not used):
# Common Event ID that will be called when the
# timer expires
AUTO_UNACCEPT_INPUT = true # Set true to turn the ACCEPT_INPUT_SWITCH_ID
# switch off when the timer expires
AUTO_STOP = true # Set true to turn the ACCEPT_INPUT_SWITCH_ID
# switch off when the timer expires
DEFAULT_WIDTH = 96 # Default width for timer sprite
# (a normal timer is 96)
DEFAULT_HEIGHT = 48 # Default height for timer sprite
# (a normal timer is 48)
# bottom-middle of screen
# can be changed to anything you want
DEFAULT_X = (Graphics.width - DEFAULT_WIDTH ) / 2
DEFAULT_Y = (Graphics.height - (DEFAULT_HEIGHT * 2)) / 2
class Properties
attr_accessor :font_color
attr_accessor :font_out_color
attr_accessor :font_size
attr_accessor :font_bold
attr_accessor :font_italic
attr_accessor :font_outline
attr_accessor :font_shadow
attr_accessor :font_name
attr_accessor :prefix_text
attr_accessor :suffix_text
attr_accessor :x
attr_accessor :y
attr_accessor :z
def initialize(x = 50, y = 0, z = 200, font_color = [180, 0, 0],
font_out_color = [255, 100, 0], font_size = 50,
font_bold = true, font_italic = false,
font_outline = true, font_shadow = false,
font_name = ["Courier New", "Myriad", "Verdana"],
prefix_text = "", suffix_text = "")
@font_color = font_color
@font_size = font_size
@font_bold = font_bold
@font_italic = font_italic
@font_outline = font_outline
@font_shadow = font_shadow
@font_name = font_name
@font_out_color = font_out_color
@prefix_text = prefix_text
@suffix_text = suffix_text
@x = x
@y = y
@z = z
end
end
end
module DataManager
class << self
alias_method(:my_create_game_objects, :create_game_objects)
alias_method(:my_make_save_contents, :make_save_contents)
alias_method(:my_extract_save_contents, :extract_save_contents)
end
def self.create_game_objects
my_create_game_objects
$ct_game_timer = CT_Game_Timer.new
end
def self.make_save_contents
contents = my_make_save_contents
contents[:ct_timer] = $ct_game_timer
contents
end
def self.extract_save_contents(contents)
my_extract_save_contents(contents)
$ct_game_timer = contents[:ct_timer]
end
end
#==============================================================================
# ** CT_Audio
#------------------------------------------------------------------------------
# This class handles timers. Instances of this class are referenced by
# $ct_game_timer.
#==============================================================================
class CT_Audio
attr_accessor :filename
attr_accessor :from_start
attr_accessor :fadein_step
attr_accessor :start_volume
attr_accessor :volume
attr_accessor :end_volume
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(filename = "Field1", start_volume = 100, end_volume = nil, fadein_increase = 5, fadein_step = 20, from_start = false)
if !filename.downcase.include?("/")
filename = "Audio/BGM/" + filename
end
@filename = filename
@from_start = from_start
@fadein_step = fadein_step
@fadein_increase = fadein_increase
@start_volume = start_volume
@volume = @start_volume
if end_volume
@end_volume = end_volume
else
@end_volume = @start_volume
end
end
end
#==============================================================================
# ** CT_Game_Timer
#------------------------------------------------------------------------------
# This class handles timers. Instances of this class are referenced by
# $ct_game_timer.
#==============================================================================
class CT_Game_Timer
attr_accessor :ct_audio
attr_accessor :paused
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@count = 0
@fade_in_count = 20
@ct_audio = nil
@working = false
@paused = false
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if !@paused
if $game_switches[CT_Timer::ACCEPT_INPUT_SWITCH_ID]
if @working && @count > 0
if CT_Timer::BUTTON_PRESS
CT_Timer::BUTTON_PRESS.each do |bp|
if Input.trigger?(bp)
$game_variables[CT_Timer::BUTTON_COUNT_VAR_ID]=
$game_variables[CT_Timer::BUTTON_COUNT_VAR_ID]+1
end
end
end
end
end
if @working && @count > 0
@count -= 1
if @ct_audio
if @ct_audio.volume < @ct_audio.end_volume
@fade_in_count += 1
if @fade_in_count >= @ct_audio.fadein_step
@fade_in_count = 0
@ct_audio.volume += 5 unless @ct_audio.volume >= @ct_audio.end_volume
p @ct_audio.volume
end
end
Audio.bgm_play(@ct_audio.filename, @ct_audio.volume)
end
on_expire if @count <= 0
end
end
end
#--------------------------------------------------------------------------
# * Start
#--------------------------------------------------------------------------
def start(count)
@count = count
@working = true
@active = true
if @ct_audio
if @ct_audio.from_start
Audio.bgm_stop
end
end
end
#--------------------------------------------------------------------------
# * Stop
#--------------------------------------------------------------------------
def stop
if CT_Timer::ACCEPT_INPUT_SWITCH_ID
$game_switches[CT_Timer::ACCEPT_INPUT_SWITCH_ID] = false
end
@working = false
end
#--------------------------------------------------------------------------
# * Determine if Working
#--------------------------------------------------------------------------
def working?
@working
end
def active?
@active
end
#--------------------------------------------------------------------------
# * Get Seconds
#--------------------------------------------------------------------------
def sec
@count / Graphics.frame_rate
end
#--------------------------------------------------------------------------
# * Processing When Timer Reaches 0
#--------------------------------------------------------------------------
def on_expire
if $game_switches[CT_Timer::ACCEPT_INPUT_SWITCH_ID]
puts "Total of buttons presses was " +
$game_variables[CT_Timer::BUTTON_COUNT_VAR_ID].to_s + " times.\n"
if CT_Timer::COMMON_EVENT_ID
$game_temp.reserve_common_event(CT_Timer::COMMON_EVENT_ID)
end
if CT_Timer::AUTO_UNACCEPT_INPUT
$game_switches[CT_Timer::ACCEPT_INPUT_SWITCH_ID] = false
end
else
if CT_Timer::AUTO_STOP
stop
end
end
@active = false
BattleManager.abort unless $game_switches[CT_Timer::STAY_IN_BATTLE_SWITCH_ID]
end
#--------------------------------------------------------------------------
# * Add more time
#--------------------------------------------------------------------------
def add_time(min = 0, sec = 0)
count = (min * 60) + sec
@count += count * Graphics.frame_rate
end
#--------------------------------------------------------------------------
# * Subtract more time
#--------------------------------------------------------------------------
def lose_time(min = 0, sec = 0)
count = (min * 60) + sec
@count = [@count - (count * Graphics.frame_rate), 1].max
end
#--------------------------------------------------------------------------
# * Pause
#--------------------------------------------------------------------------
def pause
@paused = true
end
#--------------------------------------------------------------------------
# * Resume
#--------------------------------------------------------------------------
def resume
@paused = false
end
#--------------------------------------------------------------------------
# * Pause
#--------------------------------------------------------------------------
def paused?
@paused
end
end
#==============================================================================
# ** CT_Sprite_Timer
#------------------------------------------------------------------------------
# This sprite is for ct_timer displays.
# It monitors $ct_game_timer and automatically changes sprite states.
#==============================================================================
class CT_Sprite_Timer < Sprite
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, x = Graphics.width - CT_Timer::DEFAULT_WIDTH,
y = CT_Timer::DEFAULT_HEIGHT)
super(viewport)
create_bitmap
@CT_Timer_Properties =
CT_Timer::Properties.new(x, y)
@i = 0
create_font
update
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
super
end
#--------------------------------------------------------------------------
# * Create Bitmap
#--------------------------------------------------------------------------
def create_bitmap
self.bitmap = Bitmap.new(CT_Timer::DEFAULT_WIDTH, CT_Timer::DEFAULT_HEIGHT)
end
#--------------------------------------------------------------------------
# * Create Font
#--------------------------------------------------------------------------
def create_font
self.bitmap.font.name = @CT_Timer_Properties.font_name
self.bitmap.font.outline = @CT_Timer_Properties.font_outline
self.bitmap.font.shadow = @CT_Timer_Properties.font_shadow
self.bitmap.font.bold = @CT_Timer_Properties.font_bold
self.bitmap.font.italic = @CT_Timer_Properties.font_italic
self.bitmap.font.size = @CT_Timer_Properties.font_size
self.bitmap.font.color.set(@CT_Timer_Properties.font_color[0],
@CT_Timer_Properties.font_color[1],
@CT_Timer_Properties.font_color[2])
self.bitmap.font.out_color.set(@CT_Timer_Properties.font_out_color[0],
@CT_Timer_Properties.font_out_color[1],
@CT_Timer_Properties.font_out_color[2])
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
if CT_Timer::HIDE_TIMER_SWITCH_ID
if $game_switches[CT_Timer::HIDE_TIMER_SWITCH_ID]
super
update_bitmap
update_position
update_visibility
else
self.visible = false
end
else
super
update_bitmap
update_position
update_visibility
end
end
#--------------------------------------------------------------------------
# * Update Transfer Origin Bitmap
#--------------------------------------------------------------------------
def update_bitmap
if $ct_game_timer.sec != @total_sec
@total_sec = $ct_game_timer.sec
redraw
end
end
#--------------------------------------------------------------------------
# * Redraw
#--------------------------------------------------------------------------
def redraw
self.bitmap.clear
self.bitmap.draw_text(self.bitmap.rect, timer_text, 1)
end
#--------------------------------------------------------------------------
# * Create Text
#--------------------------------------------------------------------------
def timer_text
sprintf(" " + @CT_Timer_Properties.prefix_text +
"%02d:%02d" + @CT_Timer_Properties.suffix_text,
@total_sec / 60, @total_sec % 60)
end
#--------------------------------------------------------------------------
# * Update Position
#--------------------------------------------------------------------------
def update_position
self.x = @CT_Timer_Properties.x
self.y = @CT_Timer_Properties.y
self.z = @CT_Timer_Properties.z
end
#--------------------------------------------------------------------------
# * Update Visibility
#--------------------------------------------------------------------------
def update_visibility
self.visible = $ct_game_timer.working?
end
end
#==============================================================================
# ** Spriteset_Map
#------------------------------------------------------------------------------
# This class brings together map screen sprites, tilemaps, etc. It's used
# within the Scene_Map class.
#==============================================================================
class Spriteset_Map
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias :my_init :initialize
def initialize
create_ct_timer
my_init
update
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
alias :my_dispose :dispose
def dispose
my_dispose
dispose_ct_timer
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias :my_update :update
def update
my_update
update_ct_timer
end
#--------------------------------------------------------------------------
# * Create CT_Timer Sprite
#--------------------------------------------------------------------------
def create_ct_timer
@ct_timer_sprite = CT_Sprite_Timer.new(@viewport2,
CT_Timer::DEFAULT_X,
CT_Timer::DEFAULT_Y)
end
#--------------------------------------------------------------------------
# * Free CT_Timer Sprite
#--------------------------------------------------------------------------
def dispose_ct_timer
@ct_timer_sprite.dispose
end
#--------------------------------------------------------------------------
# * Update CT_Timer Sprite
#--------------------------------------------------------------------------
def update_ct_timer
@ct_timer_sprite.update
end
end
#==============================================================================
# ** Spriteset_Battle
#------------------------------------------------------------------------------
# This class brings together battle screen sprites. It's used within the
# Scene_Battle class.
#==============================================================================
class Spriteset_Battle
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias :my_init :initialize
def initialize
create_ct_timer
my_init
update
end
#--------------------------------------------------------------------------
# * Free
#--------------------------------------------------------------------------
alias :my_dispose :dispose
def dispose
my_dispose
dispose_ct_timer
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias :my_update :update
def update
my_update
update_ct_timer
end
#--------------------------------------------------------------------------
# * Create CT_Timer Sprite
#--------------------------------------------------------------------------
def create_ct_timer
@ct_timer_sprite = CT_Sprite_Timer.new(@viewport2,
CT_Timer::DEFAULT_X,
CT_Timer::DEFAULT_Y)
end
#--------------------------------------------------------------------------
# * Free CT_Timer Sprite
#--------------------------------------------------------------------------
def dispose_ct_timer
@ct_timer_sprite.dispose
end
#--------------------------------------------------------------------------
# * Update CT_Timer Sprite
#--------------------------------------------------------------------------
def update_ct_timer
@ct_timer_sprite.update
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias :my_update :update
def update
my_update
$ct_game_timer.update
update_scene if scene_change_ok?
end
end
module BattleManager
class << self
alias_method(:my_battle_start, :battle_start)
alias_method(:my_battle_end, :battle_end)
end
def self.battle_start
if CT_Timer::PAUSE_IN_BATTLE_SWITCH_ID
if $game_switches[CT_Timer::PAUSE_IN_BATTLE_SWITCH_ID]
$ct_game_timer.paused = true
end
end
my_battle_start
end
def self.battle_end(result)
if CT_Timer::PAUSE_IN_BATTLE_SWITCH_ID
if $game_switches[CT_Timer::PAUSE_IN_BATTLE_SWITCH_ID]
$ct_game_timer.paused = false
end
end
my_battle_end(result)
end
end
#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
# This class performs battle screen processing.
#==============================================================================
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
alias :my_update :update
def update
if CT_Timer::WAIT_FOR_TIMER_SWITCH_ID
if $game_switches[CT_Timer::WAIT_FOR_TIMER_SWITCH_ID] && !$game_switches[CT_Timer::PAUSE_IN_BATTLE_SWITCH_ID]
super
if not $game_switches[CT_Timer::ACCEPT_INPUT_SWITCH_ID]
if BattleManager.in_turn?
process_event
process_action
end
end
BattleManager.judge_win_loss
else
my_update
end
else
my_update
end
end
#--------------------------------------------------------------------------
# * Update Frame (Basic)
#--------------------------------------------------------------------------
alias :my_update_basic :update_basic
def update_basic
my_update_basic
$ct_game_timer.update
end
end
#==============================================================================
# ** 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
#--------------------------------------------------------------------------
# * ct_timer
# Use this to set up a ct_timer
#--------------------------------------------------------------------------
def ct_timer(mins = 0, secs = 0, start = true, ct_game_timer = $ct_game_timer, ct_audio = nil)
if start # Start
v = (mins * 60) + secs
if ct_audio
ct_game_timer.ct_audio = ct_audio
end
ct_game_timer.start(v * Graphics.frame_rate)
else # Stop
ct_game_timer.stop
end
end
end
Code:
v2.6 (08-16-2013)
-- Added features
-- Optional Turn a switch on when the timer starts
& turn off the switch when the timer stops
v2.6.2 (09-04-2013)
-- Bug Fixes
-- Slightly cleaner code
-- Made the demo into a mini-game to help nyxzryu
v3.0 (09-19-2013)
-- Major Update
-- Basically re-wrote everything
-- Added many new features
-- Unlimited CT_Timers
-- Schedule (turn on/off switches, run common events at specified time including start & expire)
-- Much more customizable
Nice find! I think we have this handled now for my case, but it's a great find for those still looking for the script!
@Shaz , I've tested the script, and it seems it works with the Self Data Suite's Self Switches, but not self variables. It tries to change the variable I tested it with to 'true', oddly enough, and then the event it belonged to stops functioning. Do you want a copy of the SDS, so your script may be fixed?
@Shaz , I've tested the script, and it seems it works with the Self Data Suite's Self Switches, but not self variables. It tries to change the variable I tested it with to 'true', oddly enough, and then the event it belonged to stops functioning. Do you want a copy of the SDS, so your script may be fixed?
why would you set a variable to 'true'? Variables are usually numbers. Show a screenshot of your command, and screenshots of the event. I'm pretty sure my script is fine.
If you want to set it to the boolean value 'true', pass in true, not 'true'. But be sure the self data script allows you to have true as a variable value. Test that out without using the script and see what happens.
Also, not a good idea to post in one thread asking someone to check another thread. That's hijacking/off topic, even if it's your own thread.
If you want to set it to the boolean value 'true', pass in true, not 'true'. But be sure the self data script allows you to have true as a variable value. Test that out without using the script and see what happens.
Also, not a good idea to post in one thread asking someone to check another thread. That's hijacking/off topic, even if it's your own thread.
I don't want it to be set to true, the script is the one doing it. I want the variable set to 0.
I used the script call:
The console, when the timer ends, reads:
I used the script call:
Code:
$game_timer.set_ss_mt(8, 25, "Examine", 10, 0)
The console, when the timer ends, reads:
That command is changing a self switch, not a self variable.
You will need to duplicate the set_ss_mt and delete_ss_mt methods in my switch, call the new versions set_sv_mt and delete_sv_mt and change their contents so you're altering the self variables rather than the self switches.
You will need to duplicate the set_ss_mt and delete_ss_mt methods in my switch, call the new versions set_sv_mt and delete_sv_mt and change their contents so you're altering the self variables rather than the self switches.
Do you think these changes were enough? It works, but it doesn't print to the console, unfortunately. While I've made a lot of progress in leaning Ruby in the past couple of months, it's still mostly guess-and-check for me. Now all we need it a way to restart a timer. Should I just delete the current timer and start an identical one to do that?
Code:
def set_ss_mt(map, event, selfswitch, seconds, value = true)
key = sprintf('%d %d %s', map, event, selfswitch)
command = sprintf('%s[[%d,%d,\'%s\']]=%s', '$game_self_switches', map, event,
selfswitch, value)
@multi_timer[key] = [Graphics.frame_count + seconds * Graphics.frame_rate, command]
end
def set_sv_mt(map, event, selfvariable, seconds, value = 0)
key = sprintf('%d %d %s', map, event, selfvariable)
command = sprintf('%s[[%d,%d,\'%s\']]=%s', '$game_self_variables', map, event,
selfvariable, value)
@multi_timer[key] = [Graphics.frame_count + seconds * Graphics.frame_rate, command]
end
#--------------------------------------------------------------------------
# * Delete a timer
# cancels a previously set timer
#--------------------------------------------------------------------------
def delete_mt(key)
@multi_timer.delete(key)
end
def delete_ss_mt(map, event, selfswitch)
key = sprintf('%d %d %s', map, event, selfswitch)
delete_mt(key)
end
def delete_sv_mt(map, event, selfvariable)
key = sprintf('%d %d %s', map, event, selfvariable)
delete_mt(key)
end
It's not meant to print to the console - you're assigning the results to a variable, not printing them. The sprintf statements are to put all the arguments into the correct format for the self switch / self variable key and command.
It changes this:
to this:
However, unless your variables are going to be strings, I would change =%s to =%d in this line:
To restart a timer, you just execute the set_whatever_mt command again, with the new value. It will recalculate the new finish time and replace the original timer with the new one.
And good on you for getting it working. Starting with an existing script and tweaking it to do something just a little different is a great way to learn!
It changes this:
Code:
1, 2, "Explore", 5
to this:
Code:
$game_self_variables[[1, 2, "Explore"]] = 5
However, unless your variables are going to be strings, I would change =%s to =%d in this line:
Code:
command = sprintf('%s[[%d,%d,\'%s\']]=%s', '$game_self_variables', map, event,
selfvariable, value)
To restart a timer, you just execute the set_whatever_mt command again, with the new value. It will recalculate the new finish time and replace the original timer with the new one.
And good on you for getting it working. Starting with an existing script and tweaking it to do something just a little different is a great way to learn!
Hmm. Maybe the Self Data Script prints to the console whenever a self-switch is changed, but not a self-variable? I'd bet that's it.
All of my variables are strings, so I can remember them better. It's much easier for me to remember "Examine" than 5.
Ah, understood. I'll test that out. This is going to make some large progress in my game!
Thanks! I tried to modify the Free Movement script, but I only ever broke it, haha. Also, I know we haven't gotten along too well in the past, but I hope to change that going forward. Thanks for the kindness.
All of my variables are strings, so I can remember them better. It's much easier for me to remember "Examine" than 5.
Ah, understood. I'll test that out. This is going to make some large progress in my game!
Thanks! I tried to modify the Free Movement script, but I only ever broke it, haha. Also, I know we haven't gotten along too well in the past, but I hope to change that going forward. Thanks for the kindness.
no, I mean the value, not the name of the variable. But ignore what I said - I was thinking about something else.
Original thread: https://forums.rpgmakerweb.com/threads/anyone-have-a-copy-of-ct_bolts-timer-script-found.101784/