If statement and screen?

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:

If statement and screen?

#1 Post by Nanahs »

I'm using this code to let the player say when their birthday is:

Code: Select all

default bday = ""
default bmonth = ""


label whatisday:
    $ bday = int(renpy.input("Type the day - number - of your birthday.", length=2, allow = ["0","1","2","3","4","5","6","7","8","9"]) or 0)
    if bday not in range(1, 32):
        'Ups, Wrong number of day!'
        jump whatisday
        
label whatismonth:
    $ bmonth = int(renpy.input("Type the month - number - of your birthday.", length=2, allow = ["0","1","2","3","4","5","6","7","8","9"]) or 0)
    if bmonth not in range(1, 13):
        'Ups, Wrong month!'
        jump whatismonth
I have 4 different screens that say "Good morning", "Good afternoon", "Good evening", "Good night". Depending on current time.

Like this:

Code: Select all

    if hour in [17, 18, 19]:
        $hour = datetime.datetime.now().hour
        show screen afternoon
And another one that shows the current day/month:

Code: Select all

screen calendar:
        text "{size=28}[month]/[day]{/size}"  
It's all working perfectly.

The problem started when I decided to create a happy birthday screen :lol:
When it's the player's birthday, I want the game to not show the "Good morning", "good night", etc screens. I want it to show the "Happy Birthday" screen in their place during all the day.

So I tried:

Code: Select all

    if month == "bmonth" and day == "bday":
        hide screen night
        hide screen evening
        hide screen morning
        hide screen afternoon  
        show screen happybirthday
And nothing changed :oops: :lol:

I could simply choose to show both screens, putting the "Happy birthday" somewhere else. But the message stays inside of an specific frame of the background.
So I wanted to hide one to show the other. In the next day it would all go back to normal.

Also, where it's shown day/month (that is supposed to show the current day), it "freezes" on the day the person chose as their birthday.

For example, I tested it on my Android yesterday (January 30) to see how it would look like. So I set the birthday to be on January 30. When I entered the game today 1/31, instead of this screen:

Code: Select all

screen calendar:
        text "{size=28}[month]/[day]{/size}"  
Show 1/31, it froze at the "1/30" and the birthday message was still there.
Before adding this birthday thing, the screen was working properly.

Does anyone know where the mistake is? :? :?:

Thanks.

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: If statement and screen?

#2 Post by Alex »

I suspect that the problem is here

Code: Select all

if month == "bmonth" and day == "bday":
You need to compare two variables (not the text value "bmonth" / "bday"), so try

Code: Select all

if month == bmonth and day == bday:

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

Re: If statement and screen?

#3 Post by Nanahs »

Alex wrote: Thu Jan 31, 2019 4:39 pm I suspect that the problem is here

Code: Select all

if month == "bmonth" and day == "bday":
You need to compare two variables (not the text value "bmonth" / "bday"), so try

Code: Select all

if month == bmonth and day == bday:
Thank you so much! I corrected it :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], piinkpuddiin, snotwurm