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.

A way to set the playtime

Game_System Add-on (Playtime) v 1.1
by shadowball
01.11.2008


I don't know if someone already released a script like this one, but this script is how I would set the playtime in game.

It allows you to set a specific time or to add / substract a certain amount of months, days, hours or minutes.
If you try to set the time like this:
$game_system.set_time(0, 102)
it'll set the minutes to 59 min automatically.

$game_system.set_time(1, 30)
it'll add 30 min to the previous playtime

$game_system.set_time(2, 30)
it'll substract 30 min to the previous playtime

Code:
#============================
#  *  Game_System Add-on (Playtime) v 1.1
#     by shadowball
#     01.11.2008
#============================

class Game_System
  def set_time(alter = 0, min = 0, hour = 0, day = 0, mon = 0, year = 0)
    if min >= 0
      if min >= 60
        min = 59
      end
      set_min = Graphics.frame_rate * 60 * min
    end
    if hour >= 0
      if hour >= 24
        hour = 23
      end
      set_hour = Graphics.frame_rate * 60 * 60 * hour
    end
    if day >= 0
      if day >= 31
        day = 30
      end
      set_day = Graphics.frame_rate * 60 * 60 * 24 * day
    end
    if mon >= 0
      if mon > 11
        mon = 11
      end
      set_mon = Graphics.frame_rate * 60 * 60 * 24 * 31 * mon
    end
    if year >= 0 && year < 2
      set_mon = Graphics.frame_rate * 60 * 60 * 24 * 31 * 12 * year
    end
    
    case alter
    when 0
      Graphics.frame_count = 0 + set_mon + set_day + set_hour + set_min
    when 1
      Graphics.frame_count = Graphics.frame_count + set_mon + set_day + set_hour + set_min
    when 2
      Graphics.frame_count = Graphics.frame_count - set_mon - set_day - set_hour - set_min
    end
  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