Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ################################################################################
- #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
- #↓ ↓#
- #↓ Switch Timer System: Version 1.0 ↓#
- #↓ ↓#
- #↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕↕#
- #↑ ↑#
- #↑ Written By: Joe Pro ↑#
- #↑ Last Edited: July 31, 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. ◙#
- #◙ ◙#
- #◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙◙#
- ################################################################################
- #↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓#
- #↓ ↓#
- #↕ Switch Timer System: Version 1.0 ↕#
- #↑ ↑#
- #↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑#
- ################################################################################
- #==============================================================================
- # ** 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]] = 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)
- }
- 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
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def set_up_timer(goal_time, scene_type = nil, switch = nil)
- $game_system.add_timer(goal_time, scene_type, switch)
- end
- end
- #==============================================================================
- # ** 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
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment