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.

real-time clock

Real-time Clock:

This is for XP

Description:

I did a small search around the forums and couldn't find exactly what I was looking for. Does anyone know of or knows how to create a real time clock. What I mean is that when the player loads their file, a script will check their computers time. The point of this would be to have a set time for it to be morning, afternoon, or night ( and if possible I would like to display the time using an event or variables, so that I could place it where I need it.

To sum it up...I need a real-time clock script so that the game can determine what kind of light to show (morning, afternoon, night). I would also need some way to display this time, and if possible, be able to modify when and where the time hud will show.

Thanks for any help. :biggrin:
 
Here is the basics:
Code:
t = Time.now

$game_variables[1] = t.wday #Get day of the week (0-6)

$game_variables[2] = t.mon #Get month (1-12)

$game_variables[3] = t.day #Get day of the month (1-31)

$game_variables[4] = t.year #Get the year (e.g., 2009)

$game_variables[5] = t.hour #Get hour of the day (0-23)

$game_variables[6] = t.min #Get minute of the hour (0-59)

$game_variables[7] = t.sex #Get second of the minute (0-60)
That will store it in variables 1-7 (you can change that easily)

This won't work by itself, so how often would you like it to check itself?

How would you like the Time window to look like? What should be displayed?
 
not sex :biggrin:
its sec

Yeah, you'll want to change:

Code:
$game_variables[7] = t.sex #Get second of the minute (0-60)

to

Code:
$game_variables[7] = t.sec #Get second of the minute (0-60)

Just adding this here because you forgot to mention which lines it was ;o Arbiter~
 
second_crimson":2r6et1d3 said:
This won't work by itself, so how often would you like it to check itself?
Well I sort of wanted it to be a real-time clock, meaning the player could check the time constantly. So if possible, I would like it to keep checking the time, I don't know much about scripting...so I'm figuring this may lag it...but that is the general idea. Just a real-time clock for the player to check.

If that isn't exactly possible, then I would just want it to check the time at start-up and if it is at or above a certain time, it will be morning, afternoon, or night.

second_crimson":2r6et1d3 said:
How would you like the Time window to look like? What should be displayed?

As for displaying, since the script sets variables, I could probably event the display in a common event instead of needing a script to display it.



Hope this helps out a little bit...thanks for any further help :grin:
 

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