A problem with the time system

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
HiddenLife
Newbie
Posts: 13
Joined: Wed Sep 09, 2020 8:10 pm
Contact:

A problem with the time system

#1 Post by HiddenLife » Thu Dec 31, 2020 8:36 am

Hello everyone.
I'm trying to make a screen that show the current day and daytime and, when the player clicks it, jump to the next part of the day.

Here's the code:

Code: Select all

screen time():
    imagebutton yalign 0.0:
        idle "gui/time_gui.png"
        action [If(daytime >= 3, true=(SetVariable("daytime", 0), If(day >= 6, true=SetVariable("day", 0), false=SetVariable("day", day + 1))), false=SetVariable("daytime", daytime + 1))]
    hbox xalign 0.028 yalign 0.004:
        if day <= 0:
            text "Monday" size 25 color "#ffffff"
        elif day <= 1:
            text "Tuesday" size 25 color "#ffffff"
        elif day <= 2:
            text "Wednesday" size 25 color "#ffffff"
        elif day <= 3:
            text "Thursday" size 25 color "#ffffff"
        elif day <= 4:
            text "Friday" size 25 color "#ffffff"
        elif day <= 5:
            text "Saturday" size 25 color "#ffffff"
        elif day <= 6:
            text "Sunday" size 25 color "#ffffff"

        text " / " size 25 color "#ffffff"

        if day <= 0:
            text "Morning" size 25 color "#ffffff"
        elif day <= 1:
            text "Afternoon" size 25 color "#ffffff"
        elif day <= 2:
            text "Evening" size 25 color "#ffffff"
        elif day <= 3:
            text "Night" size 25 color "#ffffff"
    text "[name]" xalign 0.023 yalign 0.038 size 25 color "#ffffff"
    text "[level]" xalign 0.158 yalign 0.064 size 28 color "#ffffff"
Everything works fine. The problem is that the daytime on the screen doesen't update, but the value is correct because after four click on the imagebutton, the day change.
In particular, show a certain daytime only with a certain day. Here the abbinations:
Monday / Morning
Tuesday / Afternoon
Wednesday / Evening
Thursday / Night
Friday /
Saturday /
Sunday /
I don't know what to do and what cause this weird problem. Any idea?

Shie
Regular
Posts: 35
Joined: Sun Apr 14, 2019 4:12 am
itch: shie
Discord: Shie#3769
Contact:

Re: A problem with the time system

#2 Post by Shie » Thu Dec 31, 2020 9:30 am

if day <= 0 text morning

Probably you wanted
if daytime <= 0 text morning?

HiddenLife
Newbie
Posts: 13
Joined: Wed Sep 09, 2020 8:10 pm
Contact:

Re: A problem with the time system

#3 Post by HiddenLife » Thu Dec 31, 2020 11:01 am

Shie wrote:
Thu Dec 31, 2020 9:30 am
if day <= 0 text morning

Probably you wanted
if daytime <= 0 text morning?
Okay. I'm a complete idiot. Thank you.

Post Reply

Who is online

Users browsing this forum: mold.FF