How do I change an image according to real time?

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
User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

How do I change an image according to real time?

#1 Post by Nanahs »

In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.

It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.

How can I do it? Is it using the "If" statements?
I still get confused about it.

Thanks.

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: How do I change an image according to real time?

#2 Post by Per K Grok »

Nanahs wrote: Mon Dec 10, 2018 8:47 pm In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.

It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.

How can I do it? Is it using the "If" statements?
I still get confused about it.

Thanks.
Yes, you can use an if statement.

You use a variable (you could name it 'vHour') to hold the hour information from the time module. I am assuming you know how to do that. Is that correct?

You can then decide which image to show like this.

Code: Select all

if vHour==18 or vHour==19:
    show windowsun
elif  vHour>19 or vHour<6:
    show windowmoon

User avatar
Nanahs
Veteran
Posts: 310
Joined: Wed Aug 22, 2018 5:50 pm
Contact:

Re: How do I change an image according to real time?

#3 Post by Nanahs »

Per K Grok wrote: Tue Dec 11, 2018 2:18 am
Nanahs wrote: Mon Dec 10, 2018 8:47 pm In a scene on my game, I wanted an image to change according to the real time the person is playing.
If it's something between like 6pm till 7pm I wanted "windowsun.png" to show up and if it's from 8pm till 5am I wanted "windowmoon.png" to show up.

It's a scene in the living room. And according to the real time, I wanted it to show the window with the sun outside or with the moon.

How can I do it? Is it using the "If" statements?
I still get confused about it.

Thanks.
Yes, you can use an if statement.

You use a variable (you could name it 'vHour') to hold the hour information from the time module. I am assuming you know how to do that. Is that correct?

You can then decide which image to show like this.

Code: Select all

if vHour==18 or vHour==19:
    show windowsun
elif  vHour>19 or vHour<6:
    show windowmoon
Thank you! :)
About time, I only know how to show the current hour, and day/month/year. My knowledge stops right there I guess hah

Post Reply

Who is online

Users browsing this forum: Kocker