[Solved] Show screen/text according to the current day?

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:

[Solved] Show screen/text according to the current day?

#1 Post by Nanahs » Thu Dec 27, 2018 12:21 am

This is something I have given up on doing, but it's really something I wanted to learn how to do.

If I had a screen like this:

Code: Select all

screen christmasmessage:
    text "{color=#00ffff}Merry Christmas! Happy Holidays!{/color}" size 35 xalign 0.5 ypos 200
And I wanted it to show up if it were December 25.

In a label like this:

Code: Select all

label park:
    j "Hi Anna! How are you?"
    a "Hello Jhon! I'm fine, and you?"
If it were December 25, the "screen christmasmessage" would show up.

I'm not asking anyone to make it all for me, I just need some explanation if possible.

I've been reading many questions/codes and I got confused.
Which is the right code to import current time/day in this case?
Do I use "IF"?

I'd appreciate if someone could give me an idea on how I should try to do it :)

Thank you, and Happy Holidays everyone!
Last edited by Nanahs on Thu Dec 27, 2018 8:49 am, edited 1 time in total.

User avatar
SONTSE
Regular
Posts: 95
Joined: Sun Nov 24, 2013 10:49 pm
Completed: 8 VN's so far
Contact:

Re: Show screen/text according to the current day?

#2 Post by SONTSE » Thu Dec 27, 2018 5:34 am

Yes, you use 'if' for it. Somthing like:

Code: Select all

    if christmas:
        show screen christmasmessage
where 'christmas' is our boolean variable. We need to set it True when christmas date is met. It depends whether this date is fictional or real. If fictional, you must have additional date variables, lets say 'month' and 'day'
for this case code will be like this:

Code: Select all

$ christmas = month==12 and day==25 
and if we are looking for IRL date, i suppose we can use datetime

Code: Select all

init python:
    import datetime
    christmas = datetime.datetime.now().month==12 and datetime.datetime.now().day==25
Look! It's moving. It's alive. It's alive... IT'S ALIVE! Oh, in the name of God! Now I know what it feels like to be God!(@Henry_Frankenstein. Sums up my coding style)

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

Re: Show screen/text according to the current day?

#3 Post by Nanahs » Thu Dec 27, 2018 8:38 am

Lena_Borodach wrote:
Thu Dec 27, 2018 5:34 am
Yes, you use 'if' for it. Somthing like:

Code: Select all

    if christmas:
        show screen christmasmessage
where 'christmas' is our boolean variable. We need to set it True when christmas date is met. It depends whether this date is fictional or real. If fictional, you must have additional date variables, lets say 'month' and 'day'
for this case code will be like this:

Code: Select all

$ christmas = month==12 and day==25 
and if we are looking for IRL date, i suppose we can use datetime

Code: Select all

init python:
    import datetime
    christmas = datetime.datetime.now().month==12 and datetime.datetime.now().day==25
Thank you so much! I've been looking for a way to do that.
It really worked!! Thanks!!! :D

Post Reply

Who is online

Users browsing this forum: Google [Bot]