Help with conditional IF statements (In regards to time of 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
TAZZACORN
Newbie
Posts: 2
Joined: Sun Jun 14, 2020 7:08 am
Contact:

Help with conditional IF statements (In regards to time of day))

#1 Post by TAZZACORN »

So I'm using a day and night system in my game:

Code: Select all

default day = 1
default time_of_day = ["morning", "evening", "night"] 
default end_of_day = time_of_day[-1] # this can automatically pick up the last element of time_of_day as above.
default money = 200

label start:

label advance(increment = 1):
    python:
        while increment > 0:
            if time_of_day[0] == end_of_day:
                day += 1
            time_of_day.append(time_of_day.pop(0))
            increment -= 1
return()
These are my if statements :

Code: Select all

label Menu_Downstairs:
    if time_of_day[day] == "morning":
        scene lounge with dissolve
    if time_of_day[day] == "evening":
        scene lounge with dissolve
    else:
        scene lounge night with dissolve
&

Code: Select all

label bathroom:
    if time_of_day[day] == "morning" or time_of_day[day] == "evening":
        scene bday
    else:# time_of_day[day] == "night":
        scene bnight

    menu:
        "Have a bath.":
            jump bath

        "Exit bathroom":
            jump Menu_Downstairs

label bath:
    if time_of_day[day] == "morning" or time_of_day[day] == "evening":
        scene intub
        "I enjoy a nice relaxing bath."
        call advance(1)
        jump bathroom
    if time_of_day[day] == "night":
        scene bnight
        "It's too late for a bath."
        jump bathroom
My problem is that both of these if statements show the night scene during the evening.
So, i have no errors and it displays the morning backgrounds in the morning.
But, after my first choice, it turns to the night background, even though it's only the evening.
I want it to show day scenes during morning and evening and only night scenes at night time.
I don't know what I've done wrong. Please help me.

User avatar
MaydohMaydoh
Regular
Posts: 165
Joined: Mon Jul 09, 2018 5:49 am
Projects: Fuwa Fuwa Panic
Tumblr: maydohmaydoh
Location: The Satellite of Love
Contact:

Re: Help with conditional IF statements (In regards to time of day))

#2 Post by MaydohMaydoh »

Should be time_of_day[0] rather than time_of_day[day]

Post Reply

Who is online

Users browsing this forum: No registered users