Jump to content
Vlue

Basic Real Time (System Time)

Recommended Posts

Basic Real Time (System Time) v1.0

by V.M.

 

Introduction

 

Simple module to provide a series of functions and escape characters to incorporate system time into games.

 

Features

- Use conditional branches to activate or not based on current date or time

- Incorporate current date or time within message boxes

- Use current date and time within scripts

 

How to Use

Plug and play and read.

 

Script

Convenient Pastebin: Here

Not so convenient but more helpful link here: Here

 

FAQ

None at the moment.

 

Credit and Thanks

- By V.M. of D.T.

- Free to use in any project with credit given

Edited by Vlue

Share this post


Link to post
Share on other sites

Awesome script! Thank you very much for making it! 

 

I however need a little help with it... I want to have a christmas event on 24th of December, what eventing stuff (please provide full instructions) do I need to do?

Share this post


Link to post
Share on other sites

Just have an event that's sole purpose is to set a switch when the month is 12 and the day is 24.

Conditional branches have script options, it would be:

Rtime.month == 12 and Rtime.day == 12

Then you can set up events based on that switch

Share this post


Link to post
Share on other sites

I have some questions, too.

 

Where can I change the name of the weekday? I'm making a german game that's why I need german weekdays not english.

The same with the 12 hours system. How can I use the 24 hours system?

Edited by Shadow-Dragon

Share this post


Link to post
Share on other sites

There are options in there to use the 24 hour clock

RTime::time(true) and Rtime::hour(true)

the names of the days however are built into the ruby localization that RPG Maker uses.

I'll make a workaround for that in a bit

Share this post


Link to post
Share on other sites
There are options in there to use the 24 hour clock

RTime::time(true) and Rtime::hour(true)

 

:o Oops! I overlooked this function, sorry.

 

Edit: Sorry, but I seem to be stupid. I don't get it to work. :(

Please, can you explain me exactly what I have to do?

 

 

the names of the days however are built into the ruby localization that RPG Maker uses.

I'll make a workaround for that in a bit

 

That would be nice. Thank you.

Edited by Shadow-Dragon

Share this post


Link to post
Share on other sites

Well, what are you trying to do that involves the 24 hour clock?

 

And this is for the days, just paste this below the script and edit the names.

 

module RTime
  WEEKDAYNAMES = ["Sunday","Monday","Tuesday","Wedsnesday","Thursday",
                  "Friday","Saturday"]
  WEEKDAYABBRS = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
  def self.day(name = false, abbr = false)
    return Time.now.day if name == false
    return WEEKDAYABBRS[dayweek] if abbr
    return WEEKDAYNAMES[dayweek]
  end
end

 

Share this post


Link to post
Share on other sites

Can you add a feature, such as, if a map title name has, "[iN]" or whatever tag in the title, it makes the scripts lighting effects for night time and daytime null and resets the tint to default, like being indoors. Then when you go back onto a normal map it resumes the outdoor tint.

I remember there being a similar script for VX that allowed this, and it was a pretty handy feature.

Share this post


Link to post
Share on other sites

Thank you for the workaround. But unfortunately it works only on weekday itself not at the function "fulltime".

 

 

Within Script and Conditional Branches

That mean the script call, right?

So I tried to make a script call with "Rtime::time(true)" and "Rtime::hour(true)" in it before I show a textbox with fulltime.

Also I tried to change the setting of "Rtime::time" and "Rtime::hour" in the script itself to true. But this doesn't work, so I changed it back.

Share this post


Link to post
Share on other sites

@misttribe That'd have to be done in or with the lighting effects script.

 

@Shadow-Dragon Ah, so what you want to do is for fulltime in the textbox to show your localized day/month names and the 24 hour time instead of the 12?

 

Edit: Messed up the quoting on that.. screw it :/

Edited by Vlue

Share this post


Link to post
Share on other sites

Yeah, that's right.

"Fulltime" makes it easier for me to control what I need and what I get. (Don't forget about that I want to use "fulltime" for a clock.) I'm now in the situation that I look what this script can and to compare it with what I need. Besides, this is the only script of its kind I know. ;)

 

But don't misunderstand me, I also need the values of the 24 hours system for conditional branches and script (= script call? - 3rd eventpage).

Share this post


Link to post
Share on other sites

Try this. Also, using the call RTime::hour? will return the current hour of the day in 24 hour format for conditional branches.

 

 

module RTime
  MONTHNAMES = ["January", "February", "March", "April", "May", "June", "July", 
                "August", "September", "October", "November", "December"]
  WEEKDAYNAMES = ["Sunday","Monday","Tuesday","Wedsnesday","Thursday",
                  "Friday","Saturday"]
  WEEKDAYABBRS = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]
  def self.day(name = false, abbr = false)
    return Time.now.day if name == false
    return WEEKDAYABBRS[dayweek] if abbr
    return WEEKDAYNAMES[dayweek]
  end
  def self.fulltime
    a = WEEKDAYNAMES[dayweek] + ", "
    b = MONTHNAMES[month]
    c = Time.new.strftime(" %-d, %y %H:%M")
    return a + b + c
  end
end

 

Share this post


Link to post
Share on other sites

YAY!  Another one of my favorite scripts added with no errors to my game.  -SMILES- And I even managed to make it not rain indoors this time!  -SMILES- I'm very happy.

Share this post


Link to post
Share on other sites

I am very sorry at the lateness of discovering this wonderful script. I was just wondering...is there a way to have it show and track the month and days within the game clock? Instead of just time of day? Such as :   [Mon 22, 6:30 AM]   ?

Share this post


Link to post
Share on other sites

I am very sorry at the lateness of discovering this wonderful script. I was just wondering...is there a way to have it show and track the month and days within the game clock? Instead of just time of day? Such as :   [Mon 22, 6:30 AM]   ?

 

I think there is if you go in and read through the script on what to put in to get make the display to appear in that format.  Hang on.

 

you're wanting day of the week, number of the month, time correct?

 

Yeah if you read the header on the script it tells you how to do that.  And the first few lines of the script tells you where to put it.

 

%d %D, %H:%m %T

 

If you want to add in the month in there you want to put in

 

%d, %n %D, %H:%m %T

 

That helpful?

Share this post


Link to post
Share on other sites

 

I am very sorry at the lateness of discovering this wonderful script. I was just wondering...is there a way to have it show and track the month and days within the game clock? Instead of just time of day? Such as :   [Mon 22, 6:30 AM]   ?

 

I think there is if you go in and read through the script on what to put in to get make the display to appear in that format.  Hang on.

 

you're wanting day of the week, number of the month, time correct?

 

Yeah if you read the header on the script it tells you how to do that.  And the first few lines of the script tells you where to put it.

 

%d %D, %H:%m %T

 

If you want to add in the month in there you want to put in

 

%d, %n %D, %H:%m %T

 

That helpful?

 

 

Is there anyway you could show me a screen cap of where to implement changes? I am so lost. I wholeheartedly apologize on my lack of understanding.

 

*EDIT-again, so sorry!* I am looking to have it Display the abbrv Day of the week, the date of the month, the month abbrv, and the time and year

Edited by P3RR1N

Share this post


Link to post
Share on other sites

Line 54

    return Time.now.strftime("%A, %B %-d, %Y %l:%M")

 

Replace everything in the " " with the new string that I provided.

 

If that doesn't look right let me know.

 

edit:

 

okay I read your edit, you want it to read

 

"%a %D, %b,%H:%m %T, %Y"

 

should return something like

 

Mon 12, Oct, 12:58 pm, 2015 

Edited by Notsalony

Share this post


Link to post
Share on other sites

I must not be seeing this right. I cannot seem to find what you mentioned.

 

This is the script:

 #Basic Game Time + Night/Day v1.6.2
#----------#
#Features: Provides a series of functions to set and recall current game time
# as well customizable tints based on current game time to give the
# appearance of night and day.
#
#Usage: Script calls:
# GameTime::minute? - returns the current minute
# GameTime::hour? - returns the current hour
# GameTime::set(time) - sets the game time to time, in frames (max:1440)
# GameTime::change(time) - increments the game time! (can be negative)
# GameTime::pause_time(set) - stops time for events and stuff, true or false
# GameTime::pause_tint(set) - time runs, but tints do not update
# GameTime::clock(set) - sets whether clock is visible or not
#
#Customization: Set below, in comments.
#
#Examples: GameTime::set(360)
#
#----------#
#-- Script by: V.M of D.T
#
#- Questions or comments can be:
# given by email: sumptuaryspade@live.ca
# provided on facebook: http://www.facebook.com/DaimoniousTailsGames
# All my other scripts and projects can be found here: http://daimonioustails.weebly.com/
#
#--- Free to use in any project, commercial or non-commercial, with credit given
# - - Though a donation's always a nice way to say thank you~ (I also accept actual thank you's)

#---Game Clock---#
#USE_CLOCK to true to display game time clock
#CLOCK_POSITION for position of clock
# 1 = topleft, 2 = topright, 3 = bottomleft, 4 = bottomright
#CLOCK_TOGGLE is any input button available, see the INPUT help file for options
#------#
USE_CLOCK = true
CLOCK_POSITION = 4
CLOCK_TOGGLE = :L

module GameTime
#---Game Time Details---#
#Number of frames in a game minute, 60 frames = 1 second
TIME_COUNT = 60
#Sets whether to tint screen based on game time
USE_TINT = true

#Switch to denote day or night time
USE_SWITCH = false
NIGHT_DAY_SWITCH = 1
DAY_TIME_START = 6
NIGHT_TIME_START = 18

#True to pause time while not in map or while during a message
PAUSE_IN_COMBAT = false
PAUSE_NOT_IN_MAP = true
PAUSE_IN_MESSAGE = true

#Sets time frames of tints by minute count, one day is 1440 minutes
# 0 = 12am, 360 = 6am, 720 = 12pm, 1080 = 6pm etc...
PRESUNRISE_TIME = 240
SUNRISE_TIME = 360
NOONSTART_TIME = 660
NOONEND_TIME = 900
PRESUNSET_TIME = 1080
SUNSET_TIME = 1260
MIDNIGHT_TIME = 60 #Must be greater than 0

#Sets custome tints
PRESUNRISE_TONE = Tone.new(-75,-75,0,50)
SUNRISE_TONE = Tone.new(0,0,0,0)
NOONSTART_TONE = Tone.new(45,45,0,-25)
NOONEND_TONE = Tone.new(0,0,0,0)
PRESUNSET_TONE = Tone.new(-50,-50,0,25)
SUNSET_TONE = Tone.new(-75,-100,0,75)
MIDNIGHT_TONE = Tone.new(-125,-125,0,125)

#Include the ids of any maps not to be tinted based on time
# Usually reserved for indoor maps
NOTINTMAPS = [2]

#Store current time in a variable?
USE_VARIABLE = false
TIME_VARIABLE = 1

#---END---#

def self.init
$game_time = 360
$game_time_pause_time = false
$game_time_pause_tint = false
end
def self.update
if $game_time_pause_time then return else end
case SceneManager::scene_is?(Scene_Map)
when true
if $game_message.visible == true && PAUSE_IN_MESSAGE then else
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
when false

if !PAUSE_NOT_IN_MAP and !SceneManager::scene_is?(Scene_Battle)
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
if SceneManager::scene_is?(Scene_Battle) && PAUSE_IN_COMBAT != true
$game_time += 1 if Graphics.frame_count % TIME_COUNT == 0 end
end
if $game_time == 1440 then $game_time = 0 end
$game_variables[TIME_VARIABLE] = $game_time if USE_VARIABLE
update_night_switch if USE_SWITCH
GameTime::tint if $game_time_pause_tint != true
end
def self.update_night_switch
if hour? > DAY_TIME_START and hour? < NIGHT_TIME_START
$game_switches[NIGHT_DAY_SWITCH] = true unless $game_switches[NIGHT_DAY_SWITCH] == true
else
$game_switches[NIGHT_DAY_SWITCH] = false unless $game_switches[NIGHT_DAY_SWITCH] == false
end
end
def self.hour?
return $game_time / 60
end
def self.minute?
return $game_time % 60
end
def self.time?
meri = "AM"
hour = GameTime::hour?
minute = GameTime::minute?
if hour > 11 then meri = "PM" end
if hour == 0 then hour = 12; meri = "AM" end
if hour > 12 then hour -= 12 end
if hour < 10 then hour = " " + hour.to_s else hour.to_s end
if minute < 10 then minute = "0" + minute.to_s else minute.to_s end
return hour.to_s + ":" + minute.to_s + " " + meri
end
def self.set(number)
$game_time = number if number < 1440
GameTime::tint(0) if $game_time_pause_tint != true
end
def self.change(number)
$game_time += number
$game_time -= 1440 if $game_time > 1440
$game_time += 1440 if $game_time < 0
GameTime::tint(0) if $game_time_pause_tint != true
end
def self.tint(tint = 60)
if USE_TINT != true then return end
for i in NOTINTMAPS
if $game_map.map_id == i
$game_map.screen.start_tone_change(Tone.new(0,0,0,0),0)
return
end
end
if SceneManager::scene_is?(Scene_Map) then else return end
case $game_time
when PRESUNRISE_TIME .. SUNRISE_TIME
$game_map.screen.start_tone_change(PRESUNRISE_TONE, tint)
when SUNRISE_TIME .. NOONSTART_TIME
$game_map.screen.start_tone_change(SUNRISE_TONE, tint)
when NOONSTART_TIME .. NOONEND_TIME
$game_map.screen.start_tone_change(NOONSTART_TONE, tint)
when NOONEND_TIME .. PRESUNSET_TIME
$game_map.screen.start_tone_change(NOONEND_TONE, tint)
when PRESUNSET_TIME .. SUNSET_TIME
$game_map.screen.start_tone_change(PRESUNSET_TONE, tint)
when SUNSET_TIME .. 1440
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when 0 .. MIDNIGHT_TIME
$game_map.screen.start_tone_change(SUNSET_TONE, tint)
when MIDNIGHT_TIME .. PRESUNRISE_TIME
$game_map.screen.start_tone_change(MIDNIGHT_TONE, tint)
end
end
def self.pause_time(set)
$game_time_pause_time = set
end
def self.pause_tint(set)
$game_time_pause_tint = set
end
def self.clock(set)
return unless SceneManager.scene.is_a?(Scene_Map)
SceneManager.scene.clock_visible?(set)
end

class Window_Clock < Window_Base
def initialize
case CLOCK_POSITION
when 1
super(0,0,115,56)
when 2
super(429,0,115,56)
when 3
super(0,360,115,56)
when 4
super(429,360,115,56)
end
self.visible = $game_time_clock_visibility unless $game_time_clock_visibility.nil?
end
def update
self.contents.clear
self.contents.draw_text(0,0,100,24,GameTime::time?)
$game_time_clock_visibility = self.visible
end
end

end

GameTime::init

module DataManager
class << self
alias gametime_msc make_save_contents
alias gametime_esc extract_save_contents
end
def self.make_save_contents
contents = gametime_msc
contents[:gametime] = $game_time
contents
end
def self.extract_save_contents(contents)
gametime_esc(contents)
$game_time = contents[:gametime]
end
end


class Scene_Map < Scene_Base
alias gametime_post_transfer post_transfer
alias gametime_create_all_windows create_all_windows
alias gametime_update_map update
def post_transfer
GameTime::tint(0) if $game_time_pause_tint != true
gametime_post_transfer
end
def create_all_windows
gametime_create_all_windows
@gametimeclock = GameTime::Window_Clock.new if USE_CLOCK
end
def update
gametime_update_map
@gametimeclock.update if @gametimeclock.nil? == false
if Input.trigger?(CLOCK_TOGGLE) and @gametimeclock.nil? == false
@gametimeclock.visible ? @gametimeclock.visible = false : @gametimeclock.visible = true
end
end
def clock_visible?(set)
@gametimeclock.visible = set
end
end

class Scene_Base
alias gametime_update update
def update
gametime_update
GameTime::update
end
end

Share this post


Link to post
Share on other sites

Okay that's the day and night script, not the basic real time script.

The day and night script changes the tint to the screen and the weather.

You're wanting to change the clock which is not in the day and night script.

You're trying to apply edits to the WRONG script if that's the script your editing.

Share this post


Link to post
Share on other sites

I feel stupid....I thought I was editing this script the WHOLE time...GAH! Ty so much man!

 

*EDIT* Is there a way to swap everything to make it apply to the game? and not use my PC's time and date?

Edited by P3RR1N

Share this post


Link to post
Share on other sites

I think there is.  I think it's in the game time script.  I have to go run an errand, private message me and I'll see what I can pull up when I get home from my late lunch and see if I can help you out that way.  But I think you want Vlue's game time script.  If you can't get it to work, let me know.  -is heading out the door-

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted