def Initialize:
Allows you to set up multiple timers that turn ON assigned $game_switches upon completion.
end
def Features:
- Set-up timers that turn on assigned $game_switches.
def How to use:
More details can be found at the top of the scirpt.
end
def Script:
Spoiler
Code:
#################################################################################↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓##↓ ↓##↓ Switch Timer System: Version 0.2 ↓##↓ ↓##↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕##↑ ↑##↑ Written By: Joe Pro ↑##↑ Last Edited: August 4, 2014 ↑##↑ ↑##↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑##################################################################################◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** Disclaimer ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ This script is not for commercial, if you wish to use this script in a ◙##◙ game please PM me. All credit is to be given to me as the author of this ◙##◙ script. ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** How To Use ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ * Use the example below in an event script call to set up a new timer. ◙##◙ ◙##◙ set_up_timer(goal_time, scene_type, $game_switch_id) ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##◙ ** Updates / Version Notes ◙##◙••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••◙##◙ ◙##◙ v0.1 ◙##◙ ~◄◙◙◙◙►~ ◙##◙ * This script allows you to set up a timer to be used through out the game.◙##◙ Each timer can be assigned it's own switch. They can also be set up to ◙##◙ only update if a certian scene is running. ◙##◙ ◙##◙ v0.2 ◙##◙ ~◄◙◙◙◙►~ ◙##◙ * If the switch is on it will turn it off and visa versa when completed. ◙##◙ ◙##◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙##################################################################################↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓##↓ ↓##↕ Switch Timer System: Version 0.1 ↕##↑ ↑##↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑##################################################################################==============================================================================# ** Game_System#------------------------------------------------------------------------------# This class handles system data. It saves the disable state of saving and# menus. Instances of this class are referenced by $game_system.#==============================================================================class Game_System #-------------------------------------------------------------------------- # * Public Instance Variables #-------------------------------------------------------------------------- attr_accessor :timers # timers #-------------------------------------------------------------------------- # * Aliasing Method: Object Initialization #-------------------------------------------------------------------------- alias :gsi21321321 :initialize #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def initialize gsi21321321() @timers = {} end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def add_timer(goal_time, scene_type, switch) @timers[(@timers.size + 1)] = { :start => Graphics.frame_count, :current => Graphics.frame_count, :goal_time => goal_time, :scene_type => scene_type, :switch => switch, } end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def update_timer(id) @timers[id][:current] += 1 end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def end_timer(id) $game_switches[@timers[id][:switch]] = ($game_switches[@timers[id][:switch]] == true ? false : true) if @timers[id][:switch] @timers.delete(id) end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def time_up?(id) goal_time = @timers[id][:goal_time] current = @timers[id][:current] start = @timers[id][:start] return ((current - start) / Graphics.frame_rate) >= goal_time end #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def update_all_timers @timers.each_key { |id| if @timers[id][:scene] update_timer(id) if SceneManager.scene_is?(@timers[id][:scene]) else update_timer(id) end end_timer(id) if time_up?(id) } endend#==============================================================================# ** 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 #-------------------------------------------------------------------------- # * Object Initialization #-------------------------------------------------------------------------- def set_up_timer(goal_time, scene_type = nil, switch = nil) $game_system.add_timer(goal_time, scene_type, switch) endend#==============================================================================# ** Scene_Base#------------------------------------------------------------------------------# This is a super class of all scenes within the game.#==============================================================================class Scene_Base #-------------------------------------------------------------------------- # * Aliasing Method: Frame Update #-------------------------------------------------------------------------- alias :sbu325434 :update #-------------------------------------------------------------------------- # * Frame Update #-------------------------------------------------------------------------- def update sbu325434 $game_system.update_all_timers endenddef Credit, Licence & Commercial Usage:
This script is free to use for non-commercial use. If you want to obtain a license to use this script in a commercial game(contests included)
please PM me. Credit is to be give to myself, JoePro.
end
end
