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.

Super simple script translation (vx ace to rmxp)

I have a scriptlet that allows to add and subtract time from an active timer. It works, but it's for vx ace and now i need it for rmxp. It's only 33 lines, so i hope someone wants to take a look at it. Would help me so much!

Code:
#==============================================================================

# ** Game_Timer

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

#  Some more methods

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

 

class Game_Timer

 

  alias timer_plus_update update

  def update

    if !@pause

      timer_plus_update

    end

  end

 

  # add more time, in seconds

  def add_time(count)

    @count += count * Graphics.frame_rate

  end

 

  # subtract time, in seconds

  def lose_time(count)

    @count = [@count - (count * Graphics.frame_rate), 0].max

  end

 

  def pause

    @pause = true

  end

 

  def resume

    @pause = false

  end

end

There are the script calls:

Code:
$game_timer.add_time(20)  #add 20 seconds

$game_timer.lose_time(15) #lose 15 seconds 

$game_timer.pause         #pause countdown

$game_timer.resume        #resume countdown
 
After some more trying, i finally got it myself:

Code:
    #==============================================================================

    # ** Game_Timer

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

    #  Some more methods

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

 

class Game_System

 

  alias timer_plus_update update

  def update

    if !@pause

      timer_plus_update

    end

  end

 

  # add more time, in seconds

  def add_time(count)

    @timer += count * Graphics.frame_rate

  end

 

  # subtract time, in seconds

  def lose_time(count)

    @timer = [@timer - (count * Graphics.frame_rate), 0].max

  end

 

  def pause

    @pause = true

  end

 

  def resume

    @pause = false

  end

end
 

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