Renpy question - monday to friday, day and night system.

imaajfpstnfo

Newbie
Game Developer
Oct 25, 2019
21
62
I'm doing it like this, it's very specific to my needs and I'm sure other ways to do it are better, but I thought I'd throw in my two cents. Can't hurt.

Python:
label sleep:
    $ day += 1
    jump morning
    
screen time():
        text "{color=#FFFFFF}Day [day] ([weekday]){/color}" xpos 680 ypos 20 size 24
        if tod == 0:
            text "{color=#FFFFFF}Morning{/color}" xpos 920 ypos 20 size 24
        elif tod == 1:
            text "{color=#FFFFFF}Afternoon{/color}" xpos 920 ypos 20 size 24
       else:
            text "{color=#FFFFFF}Night{/color}" xpos 920 ypos 20 size 24

label weekday:
    if weekday == "Saturday":
        $ weekday = "Sunday"
    elif weekday == "Sunday":
        $ weekday = "Monday"
    elif weekday == "Monday":
        $ weekday = "Tuesday"
    elif weekday == "Tuesday":
        $ weekday = "Wednesday"
    elif weekday == "Wednesday":
        $ weekday = "Thursday"
    elif weekday == "Thursday":
        $ weekday = "Friday"
    elif weekday == "Friday":
        $ weekday = "Saturday"
return
The "tod" variable is set whenever the code advances the time of day to "morning" "afternoon" or "night", by jumping to their respective label.
"Weekday" is called whenever the code jumps to "morning".

I like to save locations, weekdays and such things as strings, so I can just call them with []. I could have done the same for the tod variable, but that's a relic from earlier on in development.
I'm very inexperienced and still learning.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,103
14,755
I'm doing it like this, it's very specific to my needs and I'm sure other ways to do it are better, but I thought I'd throw in my two cents. Can't hurt.
You can simplify it, while still keeping the logic behind :

Python:
# Will not be saved, but still available in the game :
define periodAsString = [ "Morning", "Afternoon", "Night" ]
define nextDay = { "Saturday": "Sunday", 
                              "Sunday": "Monday",
                              "Monday": "Tuesday",
                              "Tuesday": "Wednesday",
                              "Wednesday": "Thursday",
                              "Thursday": "Friday",
                              "Friday": "Saturday" }

screen time():
        text "{color=#FFFFFF}Day [day] ([weekday]){/color}" xpos 680 ypos 20 size 24
        text "{color=#FFFFFF}%s{/color}" % periodAsString[tod] xpos 920 ypos 20 size 24


label weekday:
    $ weekday = nextDay[weekday]
    return
 
  • Like
Reactions: imaajfpstnfo

xxx3me

Newbie
Jun 19, 2020
57
29
Considering the definition on screeens.rpy:

Code:
$ dName = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][day%7]
Any idea how can I get the week day name in another place (outside the box)? I'm trying to hide some in-game menu options based on the day of the week, like:

Code:
label callmenus:
        menu:
            "{i}Morning"
            "Park" if dName not in ["Saturday","Sunday"]:
                blablablabla

            "Beach" if dName in ["Saturday","Sunday"]:
               blublublublu
This is not working, of course :p
 

RVNSN

Drunken Pirate Skirtchaser
Game Developer
Jan 17, 2019
737
436
Considering the definition on screeens.rpy:

Code:
$ dName = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][day%7]
Any idea how can I get the week day name in another place (outside the box)? I'm trying to hide some in-game menu options based on the day of the week, like:

Code:
label callmenus:
        menu:
            "{i}Morning"
            "Park" if dName not in ["Saturday","Sunday"]:
                blablablabla

            "Beach" if dName in ["Saturday","Sunday"]:
               blublublublu
This is not working, of course :p

Have you tried something like...

Code:
label callmenus:
    if dName == 0 or dName == 6:
        menu:
            "Morning":
                jump morning

    else:
        menu:
            "Morning":
                jump morning

            "Park":
                jump park

            "Beach":
                jump beach
I didn't test this, btw, just throwing out an idea, so I might have overlooked something that would make this not work.
 
  • Like
Reactions: xxx3me

xxx3me

Newbie
Jun 19, 2020
57
29
Have you tried something like...

Code:
label callmenus:
    if dName == 0 or dName == 6:
        menu:
            "Morning":
                jump morning

    else:
        menu:
            "Morning":
                jump morning

            "Park":
                jump park

            "Beach":
                jump beach
I didn't test this, btw, just throwing out an idea, so I might have overlooked something that would make this not work.
Thanks! I did something like this to be honest, simply using "if day in [2,3, etc] (respecting the calendar where day 1 is Monday, for example, so weekends would be [6,7,13,14] and so on. But this makes me write a lot of numbers - if the game have 200 days...

That's why I was looking a way to check the names of the days of the week.
 

RVNSN

Drunken Pirate Skirtchaser
Game Developer
Jan 17, 2019
737
436
Thanks! I did something like this to be honest, simply using "if day in [2,3, etc] (respecting the calendar where day 1 is Monday, for example, so weekends would be [6,7,13,14] and so on. But this makes me write a lot of numbers - if the game have 200 days...

That's why I was looking a way to check the names of the days of the week.
The way you've shown this, dName 0 is Sunday, dName 6 is Saturday

Edit: in your code example with [dName], the days of the week are always Sunday 0, Monday 1, Tuesday 2, Wednesday 3, Thursday 4, Friday 5, Saturday 6 - this never changes

day number, which would have a different code name, like [day], tracks the number of days since starting the game and increases forever
 
Last edited:
  • Like
Reactions: xxx3me

xxx3me

Newbie
Jun 19, 2020
57
29
Damn... You're right, I was sleeping LOL I just need to check day number. I was thinking it like a continuous day counting (it's another var in my game, not day).
 
  • Like
Reactions: RVNSN

RVNSN

Drunken Pirate Skirtchaser
Game Developer
Jan 17, 2019
737
436
Right on. I still have a lot to learn myself. Btw, if you have scenes that use different images for different times of day, ConditionSwitch has been a good solution that someone in lemma soft forums suggested to me, if you haven't already found your own solution. Like I said, there's still so much I don't know, but if there's anything you're trying to make work that I've figured out or someone has shown me, I'm happy to share code to help make it happen.