Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- # Incremental Wait Timers
- # Author: ForeverZer0
- # Date: 5.9.2011
- # Version: 1.1
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- #
- # Explanation:
- #
- # This is a little scripting tool I made to schedule events through scripting
- # or script calls a little easier without the need create custom timers for
- # everything. It will also eliminate the need to create a common event if you
- # wanted to have a script call after a "Wait" command, but it would be cleared
- # if the player walked off the current map when in a normal event.
- #
- # Instructions:
- #
- # Either through a script or script call, use the following commands:
- #
- # - $game_system.wait(FRAME_WAIT, 'STRING1', STRING2, etc, etc)
- #
- # - $game_system.pause_timers(true/false)
- #
- # The first command is the one to add timers. The first argument is the number
- # of frames to wait before executing. The timers will run so long as the
- # update method of $game_system is called, which by default is during
- # Scene_Map and Scene_Battle. Any arguments after the first must being written
- # as strings, that is with either single (' ') or double (" ") quotes around
- # them. These strings will be passed to the Kernel.eval method when the timer
- # reaches 0.
- #
- # The second script call will pause the timers and keep them from updating.
- # "true" will pause them, while "false" will unpause them.
- #
- #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
- class Game_System
- attr_reader :wait_timer
- attr_reader :paused
- alias zer0_wait_timers_init initialize
- def initialize
- zer0_wait_timers_init
- # Initialize instance variables
- @wait_timers, @timers_paused = [], false
- end
- alias zer0_wait_timers_upd update
- def update
- if !@timers_paused && @wait_timers.size > 0
- # Iterate throught timers and reduce wait time for each by 1
- @wait_timers.each {|timer|
- timer[0] -= 1
- # Execute all script calls and remove timer when timer reaches 0
- if timer[0] <= 0
- (1...timer.size).each {|i| eval(timer[i]) }
- @wait_timers -= [timer]
- end
- }
- end
- # Normal update method of Game_System
- zer0_wait_timers_upd
- end
- def clear_timers
- # Clear timers by settiing array to an empty array
- @wait_timers = []
- end
- def pause_timers(bool = true)
- # Set bool value for "pause"
- @timers_paused = bool
- end
- def wait(*args)
- # Add supplied array of arguments to the timer queue
- @wait_timers.push(args)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement