The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: modern algebra on September 04, 2009, 01:52:47 PM

Title: Global Timer 1.0
Post by: modern algebra on September 04, 2009, 01:52:47 PM
Global Timer
Version: 1.0
Author: modern algebra
Date: September 4, 2009

Version History



Description


This script allows you to have the timer update in any scenes you want, not just Scene_Map and Scene_Battle

Features


Instructions

Please see the header of the script.

Script


Code: [Select]
#==============================================================================
#    Global Timer
#    Version: 1.0
#    Author: modern algebra (rmrk.net)
#    Date: September 4, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#
#    This script allows you to update the timer in any scenes you want, not
#   just Map and Battle.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#
#    Place this script above Main and below Materials.
#
#    If you wish to not have the timer update in certain scenes, go to line 33
#   and add the name of the class to the array.
#==============================================================================
# ** Scene Base
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new constant - GT_EXEMPT_SCENES
#    aliased methods - start, update, terminate
#==============================================================================

class Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * CONSTANTS
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  #  Add all the scenes where you do not want the timer to update here.
  # Scene_Map and Scene_Battle should ALWAYS be excluded since the timer is
  # already updated in those scenes. Scene_Title should also be excluded
  GT_EXEMPT_SCENES = [Scene_Map, Scene_Battle, Scene_Title, Scene_File,
    Scene_Debug]
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_timer_global_strt_6jx2 start
  def start (*args)
    malg_timer_global_strt_6jx2 (*args) # Run Original Method
    # Unless in an exempt scene or one where timer already exists
    GT_EXEMPT_SCENES.each { |scene| return if self.is_a? (scene) }
    @timer_sprite = Sprite_Timer.new (nil) # Create Timer
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Dispose
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias moda_glbl_timr_term_7hf1 terminate
  def terminate (*args)
    moda_glbl_timr_term_7hf1 (*args) # Run Original Method
    # Dispose Timer Sprite
    @timer_sprite.dispose unless @timer_sprite.nil? || @timer_sprite.disposed?
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias ma_global_timer_upd_8gv2 update
  def update (*args)
    ma_global_timer_upd_8gv2 (*args) # Run Original Method
    # Unless in an exempt scene or one where timer already exists
    return if @timer_sprite.nil? || @timer_sprite.disposed?
    timer_ending = $game_system.timer_working && $game_system.timer == 1
    $game_system.update  # Update Timer
    @timer_sprite.update # Update Timer Sprite
    # If Timer ending, go to Map
    if timer_ending
      Sound.play_buzzer
      $scene = Scene_Map.new
    end
  end
end

Credit



Thanks


Support


For support or bug reports, please post in this topic.

Known Compatibility Issues

No known compatibility issues, though it should be noted that the timer will appear in the top right corner no matter if that blocks out important details of the scene.


Creative Commons License
This script by modern algebra is licensed under a Creative Commons Attribution-Non-Commercial-Share Alike 2.5 Canada License.
Title: Re: Global Timer 1.0
Post by: Grafikal on September 04, 2009, 04:54:33 PM
I imagine a scenario where a player might be escaping from some collapsing cave and has 2 minutes to escape, but instead of pulling up the menu and going to eat dinner, you could set it so that the menu updates the timer as well? So basically, no dinner for you! For like 2 minutes lol.
Title: Re: Global Timer 1.0
Post by: modern algebra on September 04, 2009, 05:11:21 PM
Yeah, pretty much. I thought it was a pretty annoying script too, but it was an easy enough request so I did it anyway :P