Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

RMXP - Unlimited Timer System

I need a script that will allow me to make the Timer's maximum change to unlimited. So I can do 2 days, 3 months, 1 year, etc.
 
[rgss] 
#===============================================================================
# [ Script ] Timer Edit
# by Drago del Fato
# License: Free for non-commercial games. Commercial games only with approval of
#          the author.
#-------------------------------------------------------------------------------
# Instructions: Insert above main.
# To call the script run event script and just write
# run_timer(specify hours here, specify minutes here, specify seconds here)
#
#
# You can only specify hours, or hours or minutes or all three.
#
#===============================================================================
 
#-------------------------------------------------------------------------------
# Class Interpreter Edit
#-------------------------------------------------------------------------------
 class Interpreter
   def run_timer(hours, minutes = 0, seconds = 0)
      time_start = hours * 60 * 60 + minutes * 60 + seconds
      $game_system.timer = time_start * Graphics.frame_rate
      $game_system.timer_working = true
    end
  end
 
 
#-------------------------------------------------------------------------------
# Class Sprite_Timer Edit
#-------------------------------------------------------------------------------
  class Sprite_Timer < Sprite
   
   def update
    super
    # Set timer to visible if working
    self.visible = $game_system.timer_working
    # If timer needs to be redrawn
    if $game_system.timer / Graphics.frame_rate != @total_sec
      # Clear window contents
      self.bitmap.clear
      # Calculate total number of seconds
      @total_sec = $game_system.timer / Graphics.frame_rate
      # Make a string for displaying the timer
     
      day = @total_sec / 60 / 60 / 24
      @total_sec -= day * 24 * 60 * 60
      hour = @total_sec / 60 / 60
      @total_sec -= hour * 60 * 60
      min = @total_sec / 60
      sec = @total_sec % 60
     
      if day > 0
       text = sprintf("%02d:%02d:%02d:%02d", day, hour, min, sec)
      elsif hour > 0
       text = sprintf("%02d:%02d:%02d", hour, min, sec)
      else
       text = sprintf("%02d:%02d", min, sec)
      end
      # Draw timer
      self.bitmap.font.color.set(255, 255, 255)
      self.bitmap.draw_text(self.bitmap.rect, text, 1)
    end
  end
end
 
[/rgss]

Here. I added so you can set hours, minutes and seconds. If you need days just calculate them into hours (number of days * 24).

Hope it helps. :)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top