Making a Real-time Game

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
mapletaffy
Regular
Posts: 96
Joined: Sat Apr 30, 2011 10:54 pm
Contact:

Making a Real-time Game

#1 Post by mapletaffy »

Hello,

Is there a way (or is it even possible) to "fetch" the local system time so it can trigger the events in-game for a real-time effect? I made a fake code as an example:

Code: Select all

start
get.systemlocaltime
if systemlocaltime >=1:00 jump midnight
if systemlocaltime >=7:00 jump morning
if systemlocaltime >=18:00 jump evening

label midnight:
renpy.random.events(("event1", "event2", "event3"))
event1:
"What are you doing here? It's already midnight"
event2:
"zZzZzZzZ"
event3:
"Hey, Why are you still awake?"

label morning
renpy.random.events(("event1", "event2", "event3"))
event1:
"Hi. Good morning."
event2:
"Can we go to school together?"
event3:
"zZzZzZz"

label evening:
renpy.random.events(("event1", "event2", "event3"))
event1:
"I'm sleepy. . ."
event2:
"I'm eating dinner right now."
event3:
"Good night!"
Thank you so much!

User avatar
netravelr
Miko-Class Veteran
Posts: 504
Joined: Thu Jan 28, 2010 2:31 am
Completed: Culina: Hands in the Kitchen, Culina: The Spirit of Cooking, Saving Zoey
Projects: Love at the Laundromat
Organization: Lakeview Interactive
Deviantart: netravelr
Location: USA
Contact:

Re: Making a Real-time Game

#2 Post by netravelr »

Well,

Python has a system called datetime (http://docs.python.org/2/library/datetime.html) but I don't know anything RenPy has by default has time settings. Hopefully this'll work out for you if you read it carefully.

Cheers!
Image
Technical Designer/Programmer
Game Design Portfolio - Project updates on my Twitter
Experienced in: C/C++/C#, Python, Unreal, Unity, and Flash
_________________
"Space can be very lonely. The greatest adventure is having someone share it with you."

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Making a Real-time Game

#3 Post by PyTom »

The time settings are taking out of the OS, so assuming the OS has correct time, the various datetime function should work without problem.

You can also use time.time() if all you need is seconds since January 1st, 1970 midnight UTC - which is a surprisingly useful thing to need.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

mapletaffy
Regular
Posts: 96
Joined: Sat Apr 30, 2011 10:54 pm
Contact:

Re: Making a Real-time Game

#4 Post by mapletaffy »

Oh, I see. Thank you for all the information! :D

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], giorgi1111, Google [Bot], Ocelot