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.

[Request] Add time to the ingame timer.

RMXP or RMVX:
RMXP
Detailed Description:
I need to be able to add time to the ingame timer, and if possible have a "+ 5 seconds" appear under the clock when time is added

Other Scripts I am using (in order):
The only script that actually affects the timer that I have is:
Code:
#  Written by: Kain Nobel

#  Version: 0.5

#  Last Update: 5/13/2008

#  Date Created: 10/17/2008

#===============================================================================

TimerCriticalSwitch = 0

#===============================================================================

#  INSTRUCTIONS:

#    This is just an enhanced version of Sprite_Timer default class, with a few

#  small changes I decided to make to it. Now it not only displays minutes and

#  seconds in the string, but also milli-seconds... yes, a fraction of a second,

#  and it updates in real time too! (Provided your computer isn't fucked!)

#    Lastly, it detects the total set time vs current time, and sets a caution

#  and critical color when the timer reaches a certain point, such as 1/2 or 3/4

#  the set time.

#-------------------------------------------------------------------------------

class Sprite_Timer < Sprite

  #------------------------

  # * Object Initialization

  #------------------------

  def initialize

    super

    # Variable used to determine timer critical

    @critical = -1

    self.bitmap = Bitmap.new(120, 48)

    self.bitmap.font.name = "Arial"

    self.bitmap.font.size = 32

    self.x = 640 - self.bitmap.width

    self.y = 0

    self.z = 500

    update

  end

  #------------------------

  # * Dispose

  #------------------------

  def dispose

    if self.bitmap != nil

      self.bitmap.dispose

    end

    super

  end

  #------------------------

  # * Frame Update

  #------------------------

  def update

    super

    # Set Timer to visible if working

    self.visible = $game_system.timer_working

    # If Timer needs to be withdrawn

    self.bitmap.clear

    # Get @total_sec value

    @total_sec = $game_system.timer / Graphics.frame_rate

    frac = $game_system.timer % Graphics.frame_rate

    sec_fraction = frac.to_f / Graphics.frame_rate.to_f

    sec_fraction *= 100

    min = @total_sec / 60

    sec = @total_sec % 60

    # Send min, sec, millisec info to a string.

    text = sprintf("%02d:%02d:%02d", min, sec, sec_fraction)

    # If Critical is equal or less than 0, set to @total_sec / 2

    if $game_switches[TimerCriticalSwitch] == true

      # Auto-Set critical time to 1/2 timer set time

      if @critical == -1

        @critical = (@total_sec / 2)

      end

      # If @total_sec is more than (Timer Setting / 2) ?

      if @total_sec >= @critical

        self.bitmap.font.color.set(204, 224, 240)

      # If @total_sec is equal to or more than (Timer Setting / 4) ?

      elsif @total_sec >= (@critical / 2)

        self.bitmap.font.color.set(255, 200, 0)

      else

      # @total_sec is less than Timer Critcal Variable!

        self.bitmap.font.color.set(255, 0, 0)

      end

    else

      # Switch is off, automatically set to default color

      self.bitmap.font.color.set(204, 224, 240)

    end

    # Draw the timer value from string 'text'

    self.bitmap.draw_text(self.bitmap.rect, text, 1)

  end

end

Please and thank you
 
Have you seen this thread? It was posted last Friday, and quickly resolved the same issue you seem to have. Just take a quick look through, see if you can work with it. As for the +5 seconds, that could easily be solved by having the same event temporarily display that as a picture, under the timer.
 
Thank you so very much! The picture idea never even occurred to me, lol o.o

Edit: its actually working kinda weird i'll mess around with it a bit more and tell you the results

2nd Edit: The timer is working really odd I'm using the following event comments

Control variables[4th one] blah blah blah + 12000
v=$game_variables[4]
s=$game_system
s.timer=v
s.timer_working=true

This works fine, it sets me up with a 5 minute timer

Now when I set a variable as the timer it changes the variable to the number of seconds, and your script appears to work with frames, could you please tell me a fix for this?


Final Edit:

Ok it seems I had to

Set the variable to the time
Multiply the variable by 40
Then add seconds by 1/40th incriminates

Thanks again!
 

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