I am an idiot, Please Help Me Learn Ren'Py.

Update: Thanks to both of you for your help! I am able now to get the fatness variable to work!

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define s = Character("Sophie")

#Kayla is a bottom-heavy blonde with secret feedee and lesbian preferences

define a = Character("Anna")

#Anna is a busty and fit girl with long dyed-red hair.

default sophiefatness = 0

init python:
    def tick(amount=1):
        global time, time_map
        
        time += amount
        if time > len(time_map):
            time %= time_map

default time = 0

define time_map = [
    "morning",
    "day",
    "noon",
    "afternoon",
    "evening",
    "night",
    "latenight"
]

# The game starts here.

label start:

s "My first day on-campus. You can do this, Sophie. It's just college, almost everybody has done it."

s "I've just gotta study hard, make some friends-"

s "-and avoid that freshman 15 my mom kept warning me about..."

"My cheeks start to turn red, warmth rushing to my face."

s "Why am I blushing over that? W-whatever..."

s "Made it to the apartment I found online. That ad really came in just when I needed it most!" 

s "A place this big would be a lot more expensive usually, but there's another roommate here to split the rent with!"

s "I wonder what my roommates will be like?"

s "Time to find out, I guess."

scene dormroomempty

s "Hello? Anybody home?"

a "Yes? Who are you?"

s "Oh! I'm Sophie!"

"The girl stares at me blankly for a moment."

s "I'm uh... your new roommate!"

a "Ohh! You're the one who responded to my ad on Greg's List!"

a "You know, before you came along, I wasn't sure anyone was gonna respond to that ad."

a "I almost forgot about it and planned on posting ads locally instead."

s "W-well I'm glad you didn't! I uh, really needed this place."

"Now that the introductions were done, I took a moment to look at my new roommate for the first time."

"Anna was gorgeous. Seriously, she could be a model! Those beautiful crimson locks, those piercing green eyes, that flawless skin..."

"AND THOSE HUGE TITS! LOOK AT THE SIZE OF THOSE THINGS!"

a "Earth to Sophie? Hello?"

s "Huh? S-sorry I'm here! What did you say, again?"

a "I asked if it was okay to go over a few house rules with you. But if you're so distracted by something right now..."

s "N-no I'm fine! I promise!"

a "Then good. Alright, well, each day, feel free to do whatever you want around here."

a "Though I recommend eating meals and going to class, obviously."

a "If you ever want to hangout or anything like that, just let me know!" 

a "Though, I really like my beauty sleep, so I won't be down to hangout in the early morning or late at night."

a "Some things just aren't doable at different times, ya know?"

s "R-right, I guess."

a "With that tutorial, I mean explanation, out of the way, why don't we get something to eat?"

s "Huh?"

a "It's already noon! Surely you need to stop and get some lunch, you've been busy all-day moving!"

s "W-well, maybe..."

"Admittedly, I had already had a decent enough lunch just an hour or two before. I made a sandwich or two back at my parent's place."

"But I wasn't sure if I wanted to pass up an opportunity to get to know my new roommate on the first day, before classes even started!"

menu:
    a "So, yes or no on the lunch break?"
    "Sounds good to me!":
        jump firstbinge

    "I kinda wanna get setlled in right now. Maybe another day?":
        jump dayonedeny


label firstbinge:
a "Awesome! You're gonna love this!"
"Anna jumped from where she was standing and rushed off to the kitchen, immediately pulling things out of the fridge."
a "I may be a Psychology major, but my REAL passion is cooking!"
s "Oh wow!"
"My mouth began to water a bit as I smelled the distinct scent of cooking meat."
s "Whatcha makin'?"
a "Burgers! I had some frozen ones lying around, and I can make 'em extra special!"
s "Looking forward to it!"
"I waited for around 10-15 minutes while Anna cooked."
a "I hope you're hungry!"
"Anna reappeared with a platter of burger patties stacked high, about 7 of them."
s "This is... a lot of food, Anna!"
a "Sorry, I'm awful at cooking smaller portions of food..."
a "Anything we don't finish is leftovers, okay?"
s "Alright..."
"And so we got to talking a bit. I learned she was a psychology major and culinary arts minor."
"I learned her family owned this property, so she got to live here for basically free."
"I told her that I came here to study art and communications."
"She was a sophomore, I was a freshman."
"And so we kept talking and eating, splitting the tray of burgers..." 
"I say 'Splitting' but in reality she only ate two of them. The other five... my bad."
s "Getting... full... ugh."
a "Sorry about that, Sophie."
a "I maybe went overboard for today."
s "It's okay."
a "Just relax a bit and let that digest okay? Won't do you any good to get an upset tummy on the first day here."
s "Fair point..."
"Anna got up and cleaned the whole mess up, before giving me one last look and smiling."
a "I think you and I are gonna get along perfectly, Sophie."
"For some reason, this sent a chill up my spine."
$ sophiefatness += 1
jump daily_choice


label dayonedeny: 
a "Oh uh, okay! Fair enough."
a "Feel free to hit me up to hangout, okay?"
"I felt a little bad ditching her, but I'd already eaten lunch."
"Time to start my first day!"
jump daily_choice

  #Example menu#

label daily_choice:
if sophiefatness == 1:
    a "We did it!"
else:
    s "Aww shucks."
    # This ends the game.
return

This works as-expected and makes a good base for variable tracking! Thanks all!

Now to figure out how time works. I’m a bit overwhelmed by you guys’ explanations, and I’m trying to get the game to start at afternoon on day 1, progress by 1 stage with each event you choose, and each day starts at morning. Using these actions:

label daily_choice:
menu choices:
    "Have breakfast" if time == "morning" or "day":
        jump eat_breakfast
    "Have lunch" if time == "noon" or "afternoon":
        jump eat_lunch
    "Have dinner" if time == "evening" or "night":
        jump eat_dinner
    "Go to class" if time == "morning" or "day" or "noon" or "afternoon":
        jump class
    "Go to work" if time == "day" or "noon" or "afternoon":
        jump work
    "Look in the mirror":
        jump mirror
    "Have a shower":
        jump have_shower
    "Go shopping" if time == "day" or "noon" or "afternoon" or "evening":
        jump go_shopping
    "Go to the gym":
        jump gym
    "Go to the beach":
        jump beach
    "Go for a run" if time == "morning" or "day" or "noon" or "afternoon" or "evening":
        jump park
    "Go out partying" if time == "evening" or "night" or "latenight":
        jump parties
    "Hangout with Anna" if time == "day" or "noon" or "afternoon" or "evening" or "night":
        jump hangout
    "Wait":
        jump wait
    "Go to sleep early" if time == "afternoon" or "evening":
        jump early_night
    "Go to bed" if time == "night":
        jump sleep

1 Like

catching my own error and another one here but timestr needs to be listed in the global variables of the function tick, also length of time_map would return 7 but time string needs to roll over at values greater than 6 so its length of list minus 1 because lists start at 0 not 1


I’m probably over explaining however i’m not sure what part your missing so here it goes.

So time is some what arbitrary, we could make an actual clock variable counting time in actual hours and assign hour ranges for each time period you want, but that would be silly because that would only add complexity so for example if i have 3 periods morning afternoon and night that i actually care about. i could make a arbitrary clock with values 0, 1, 2 the time between 0 and 1 would be morning, the time between 1 and 2 would be afternoon, and the time between 2 and 0 would be night. Simplifying further lets just make 0 morning, 1 afternoon, and 2 night. So now the “clock” in python would be an integer and we would know the time based on its value. if the variable we made for time is 1 we know it would be afternoon. So now the problem is we want to be able to get string “afternoon” out of something when we give it a number representing the time. As it happens a list will do this for us.

Ignoring values for a second you have a variable for time, in this case time. you also have a list of time periods time_map. You want to complete two things with these variables one is to track the time, the other is to beable to output the time as a string.

So if time_map is a list of strings that represent time in words, then to get an item or time out of the list i would do listname[ keyorlistposition ]. if the list is in order of increasing times then since a lists first position is 0 the frist value in the list would be returned by listname[ 0 ]

define time_map = [
    "morning",          #this item is at position 0
    "day",              #this item is at position 1
    "noon",             #this item is at position 2
    "afternoon",        #this item is at position 3
    "evening",          #this item is at position 4
    "night",            #this item is at position 5
    "latenight"         #this item is at position 6
]

so with your list time_map and an integer time we can extract the time. since the value of time starts at 0 with out chanting it time_map[ time ] would result in the string “morning”.

So now all we have to do is change the time variable, and it would result in getting different time periods out of time_map. if time is 1 you get “day”, make it 5 you get “night”.

You could change the time variable manually with something like $ time +=1, so then why the make the function. For safety and easy re-usability. Every time we incerment the time variable if we increment past 6 to 7 like a clock we should roll back around to 0. Also we want to store the string returned by time_map[time] in timestr every time time changes. So without the function we would actually need these lines

$ time += amount
if time > len( time_map ) - 1 :
    $ time %= len( time_map )
$ timestr = time_map[ time ]

which is now four lines we have to add where ever we want to change the time to be able to do something with it. So using a function tick that does those four lines for us each time we call it makes it so every time we want to advance the time you only need one line

$ tick( amount )

The function is all about making life simpler every time you want to change the time. The function is just a wrapper for an block of code we want to be able to repeat same as a label is for renpy script.

A quick two tangents in case you did not recognize len( listvariablehere ) is a built in function to python to return the length of a list or how many items are in it. Second is in case you didn’t follow why we %= the length of time periods list, is because if we are incrementing by say 3(amount is 3) then if time was 5, temporarily before %= time would be 8 but the clock should roll back to 1(5+1 is 6, 6+1 is 0, and 0+1 is 1 on a clock incrementing by 3) which happens to be the same as 8 %= 7(the length of your list)

Ok so if i have not lost you yet and are a keen observer, you at this point realized you don’t yet have a variable to track how many days have gone by. So first we need a new integer variable, next any time the clock would roll over which we are already checking for in our function tick we should go ahead and increment the day tracking variable(to be able to do this in or function it would also need to be added to the list of global variables of our function tick). I think if your following you can probably make these additions, if not ask more questions.

Ok finally we are to using our function tick, since we gave the passed variable(amount) a default value of 1 we actually don’t need to pass anything to tick to increment by 1, and just have to call tick $ tick() . If we wanted to change by two time periods amount would need to be 2 so then we would call $ tick(2) .

So now any time in your script the time should advance you use your function tick and from my previous post any time you want to use your time string in a sentance you use [ timestr ]. Also once you have added the day variable any time you want to output the day variable you add [ dayvariablenamehere ] to the script.

I hope my wall of text explains everything, and is not to much.

Edit:
I forgot to tie this all back to your choice menu
you have conditions like

if time == "morning" or "day":

There’s a few problems rember that your asking if your variable time which will be a number such as 1 is equal to a string “morning”, we need to compare apples to apples to get it to evaluate to true. also “morning” or “day” would always evaluate to true same with 1 or 0 , what you actually mean or want is

if ( time == 0 ) or ( time ==  1 ):

or

if ( timestr == "morning" ) or ( timestr == "day" ):

while the parentheses are not necessary here they make it clearer what is going on at a glance

p.p.s
initiate time with its value = 3 to represent afternoon to start so
default time = 0 becomes default time = 3

1 Like

You don’t actually need that if condition there, as the modulus operator can always be applied, just use:

time %= len(time_map)

yes, but if hes tracking the number of days gone by it is useful because it allows detection of when the “clock” is rolling over

there is also the problem that may not really be a problem of what happens when amount >= len(time_map)

Again, you don’t need to detect it just for time and day, see my original example. It’s actually safer that way as it guarantees the list index will always be in bounds (ie. between 0 and len-1).

Yes, i see how your code works. Yes, i agree that it is better.

However, he made is own attempt to write the function, and while his method may be messier or not do it the best way, following his line of thinking i was helping complete the task. Short of saying just copy and pasting your code there is nothing wrong as long as you know the limits of your code and are ok with them.

So, I think I got the gist of time stuff? But, first, I’m hitting an odd roadblock.

For some reason, I just cannot get TAKE A SHOWER to appear on my menu of daily choices. For some reason, mirror and shower always replace each other if I edit the code even slightly, and I can only see one of them at a time, but all the other options work as intended. idk.

menu choices:
    #ANYTIME
    "Take a shower" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5) or ( time == 6 ):
        jump have_shower
    "Look in the mirror" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5) or ( time == 6 ):
        jump mirror
    #ENDS AT DAY
    "Have breakfast" if ( time == 0 ) or ( time ==  1 ):
        jump eat_breakfast
    #ENDS AT AFTERNOON
    "Go to class" if ( time == 0 ) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ):
        jump class
    "Go to work" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ):
        jump work
    "Have lunch" if ( time ==  2 ) or ( time ==  3 ):
        jump eat_lunch
    #ENDS AT EVENING
    "Go shopping" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ):
        jump go_shopping
    "Go for a run" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ):
        jump park
    #ENDS AT NIGHT
    "Hangout with Anna" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump hangout
    "Go to the gym" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5):
        jump gym
    "Go to the beach" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump beach
    "Have dinner" if ( time == 4 ) or ( time == 5 ):
        jump eat_dinner
    "Wait" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump wait
    #LATENIGHT BITES
    "Go out partying" if ( time == 5 ) or ( time == 6):
        jump parties
    "Go to bed" if ( time == 4 ) or ( time == 5 ) or ( time == 6):
        jump sleep

After this, i need to nail down exactly what code to use to advance time, and where to put it.

oh! Also! What similar line of code do I need to make it so that certain activities are only certain days? No school on a sunday and all that.

There’s a limit to how many options will fit on the screen in a menu (it depends, but 7 or 8 I think unless you start altering the layout of the menu itself - which is a complex topic), you may be running into this.

You may need to group some choices together to make this menu smaller, for example:

  • Bathroom (mirror, shower)
  • Going out (shopping, run, hangout, gym, beach, party)

okay gotcha ill update if that changes anythin

Update: It fixed but uh

What do I do to make it not stuck to the top

1 Like

It looks like you can get a maximum of 9 choices on your menus with your screen dimensions. You’ll have to make sure this is the maximum you offer at any time. Grouping all the “going out” ones into another sub-menu would sort it. Or you could have exercise as one to then offer gym or run.

Another approach would be to split them by location, so beach could offer relax or run for example, and town could be shopping, gym, hangout. The idea of locations tend to give a little more depth to your story and are a good way to reduce the number of choices offered in one place

When you make sub-menus for a group it can be useful to have a “Back”, “Go home” or “Changed my mind” option that goes back to the main choice menu.

The space at the bottom can’t be used - it’s for a menu prompt. You can write menus like this:

menu:
    "What should I do next?"
    "Choice 1":
         jump thing1

The one line in quotes without a “:” at the end of it appears at the bottom of the screen, like narration.

Once you are tracking how many days have gone by if the game started on a monday day 1 would be monday making day 7 and every mutiple of seven a sunday. Therefore you could check for if
( daycountvariable % 7 == 0 )
if your starting on any other day of the week lets say tuesday you just need to offset to reflect when a day is, in the case of starting on tuesday, sunday would be
( ( daycountvariable - 1 ) % 7 == 6 )
starting on a saturday would be
( ( daycountvariable - 5 ) % 7 == 2 )

P.S.
An alternative that would probably be more easy in the long run to be able to see what you did if you made a list of days like @dingotush did then got the day from that. To alter the start day just put the day you want to start on on list position 1 then fill in spots 0-6 accordingly to make a week

1 Like

at the end of every event you write that takes up a certain number of time periods you just put
$ tick(amount)
where amount is the time in number of periods that that activity has used up.

The simplest solution is to keep a separate variable for dayOfWeek (0-Monday, 1-Tuesday … 6-Sunday - this is chosen for compatibility with Python’s Calendar class). To check for a weekday you look for dayOfWeek <= 5, a weekend is dayOfWeek >= 6. I included this dayOfWeek variable in my original example. These tests are simple to add as functions if it’s a check you’d use alot:

def isWeekday():
    return dayOfWeek <= 5

def isWeekend):
    return dayOfWeek >= 6

If you wanted to say check for Thursday being game night you just need to check if dayOfWeek == 3.

But, as everyone is ignoring the solution I gave you I see little point in contributing futher on this matter of time tracking.

I’m trying to use this code to make which days are and are not weekdays and weekends but… this is my result

# The script of the game goes in this file.

# Declare characters used by this game. The color argument colorizes the
# name of the character.

define s = Character("Sophie")

#Kayla is a bottom-heavy blonde with secret feedee and lesbian preferences

define a = Character("Anna")

#Anna is a busty and fit girl with long dyed-red hair.

default sophiefatness = 0

init python:
    def tick(amount=1):
        global time, time_map, timestr
        time += amount
        if time > len(time_map) - 1:
            time %= len(time_map)     
        timestr = time_map[time]    

default daysOfWeek = 6

define  daysOfWeek = [
        "Monday",       # 0
        "Tuesday",      # 1
        "Wednesday",    # 2
        "Thusday",      # 3
        "Friday",       # 4
        "Saturday",     # 5
        "Sunday",       # 6
    ]

def isWeekday():
    return daysOfWeek <= 5

def isWeekend():
    return daysOfWeek >= 6
            
default time = 3

define time_map = [
    "morning", #0
    "day", #1
    "noon", #2
    "afternoon", #3
    "evening", #4
    "night", #5
    "latenight" #6
]

# The game starts here.

label start:

s "My first day on-campus. You can do this, Sophie. It's just college, almost everybody has done it."

s "I've just gotta study hard, make some friends-"

s "-and avoid that freshman 15 my mom kept warning me about..."

"My cheeks start to turn red, warmth rushing to my face."

s "Why am I blushing over that? W-whatever..."

s "Made it to the apartment I found online. That ad really came in just when I needed it most!" 

s "A place this big would be a lot more expensive usually, but there's another roommate here to split the rent with!"

s "I wonder what my roommates will be like?"

s "Time to find out, I guess."

s "Hello? Anybody home?"

a "Yes? Who are you?"

s "Oh! I'm Sophie!"

"The girl stares at me blankly for a moment."

s "I'm uh... your new roommate!"

a "Ohh! You're the one who responded to my ad on Greg's List!"

a "You know, before you came along, I wasn't sure anyone was gonna respond to that ad."

a "I almost forgot about it and planned on posting ads locally instead."

s "W-well I'm glad you didn't! I uh, really needed this place."

"Now that the introductions were done, I took a moment to look at my new roommate for the first time."

"Anna was gorgeous. Seriously, she could be a model! Those beautiful crimson locks, those piercing green eyes, that flawless skin..."

"AND THOSE HUGE TITS! LOOK AT THE SIZE OF THOSE THINGS!"

a "Earth to Sophie? Hello?"

s "Huh? S-sorry I'm here! What did you say, again?"

a "I asked if it was okay to go over a few house rules with you. But if you're so distracted by something right now..."

s "N-no I'm fine! I promise!"

a "Then good. Alright, well, each day, feel free to do whatever you want around here."

a "Though I recommend eating meals and going to class, obviously."

a "If you ever want to hangout or anything like that, just let me know!" 

a "Though, I really like my beauty sleep, so I won't be down to hangout in the early morning or late at night."

a "Some things just aren't doable at different times, ya know?"

s "R-right, I guess."

a "With that tutorial, I mean explanation, out of the way, why don't we get something to eat?"

s "Huh?"

a "It's already noon! Surely you need to stop and get some lunch, you've been busy all-day moving!"

s "W-well, maybe..."

"Admittedly, I had already had a decent enough lunch just an hour or two before. I made a sandwich or two back at my parent's place."

"But I wasn't sure if I wanted to pass up an opportunity to get to know my new roommate on the first day, before classes even started!"

menu:
    a "So, yes or no on the lunch break?"
    "Sounds good to me!":
        jump firstbinge

    "I ate before coming, sorry. Maybe another day?":
        jump dayonedeny


label firstbinge:
a "Awesome! You're gonna love this!"
"Anna jumped from where she was standing and rushed off to the kitchen, immediately pulling things out of the fridge."
a "I may be a Psychology major, but my REAL passion is cooking!"
s "Oh wow!"
"My mouth began to water a bit as I smelled the distinct scent of cooking meat."
s "Whatcha makin'?"
a "Burgers! I had some frozen ones lying around, and I can make 'em extra special!"
s "Looking forward to it!"
"I waited for around 10-15 minutes while Anna cooked."
a "I hope you're hungry!"
"Anna reappeared with a platter of burger patties stacked high, about 7 of them."
s "This is... a lot of food, Anna!"
a "Sorry, I'm awful at cooking smaller portions of food..."
a "Anything we don't finish is leftovers, okay?"
s "Alright..."
"And so we got to talking a bit. I learned she was a psychology major and culinary arts minor."
"I learned her family owned this property, so she got to live here for basically free."
"I told her that I came here to study art and communications."
"She was a sophomore, I was a freshman."
"And so we kept talking and eating, splitting the tray of burgers..." 
"I say 'Splitting' but in reality she only ate two of them. The other five... my bad."
s "Getting... full... ugh."
a "Sorry about that, Sophie."
a "I maybe went overboard for today."
s "It's okay."
a "Just relax a bit and let that digest okay? Won't do you any good to get an upset tummy on the first day here."
s "Fair point..."
"Anna got up and cleaned the whole mess up, before giving me one last look and smiling."
a "I think you and I are gonna get along perfectly, Sophie."
"For some reason, this sent a chill up my spine."
$ sophiefatness += 1
jump daily_choice


label dayonedeny: 
a "Oh uh, okay! Fair enough."
a "Feel free to hit me up to hangout, okay?"
"I felt a little bad ditching her, but I'd already eaten lunch."
"Time to start my first day!"
jump daily_choice

  #Example menu#

label daily_choice:

s "It's already after noon!"
s "It's Sunday, so I don't have to worry about classes, but..."
s "What should I do today?"
menu choices:
#Includes Mirror and Shower
    "Go to the bathroom":
        jump bathroomchoices
#Includes Breakfast, Lunch, and Dinner
    "Make Something to Eat" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump kitchenchoices
    "Go to Class" if ( time == 0 ) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) and isWeekday:
        jump class
    "Go to Work" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) and isWeekday:
        jump work
    "Hangout with Anna" if ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump hangout
#Includes Trying-On Clothes and Changing Clothes
    "Go to Wardrobe:":
        jump wardrobechoices
#Includes Shopping, Beach, Gym, Running
    "Go Outside" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5):
        jump outsidechoices
    "Wait" if ( time == 0) or ( time ==  1 ) or ( time ==  2 ) or ( time ==  3 ) or ( time == 4 ) or ( time == 5 ):
        jump wait
#Late Night Options
    "Go out partying" if ( time == 5 ) or ( time == 6):
        jump parties
    "Go to bed" if ( time == 5 ) or ( time == 6):
        jump sleep

# This ends the game.
return

Also, I’m unsure of how to write on each event adding +1 to time, and adding +1 to day at the end of each day

okay, resumed work on my primary project and encountered… this?

what the hell is happening here

EDIT: Fixed the issues, but ugh why is it impossible to see the error text

To fix this you need to change this section so you’ve two variables with different names:

  • dayOfWeek - the number represent which day it is
  • daysOfWeek - the list of each days name

Right now you assign 6 to daysOfWeek, then assign a list to it (actually it’s more complicted because of the way default, define, and loaded games work):

default daysOfWeek = 6

define  daysOfWeek = [
        "Monday",       # 0
        ....

Change to:

default dayOfWeek = 6         # The current day of the week

define  daysOfWeek = [        # The names of each day of the week
        "Monday",       # 0
        ....

The two new Python functions need to go in the init python block, and test the right variable dayOfWeek (the number) rather than daysOfWeek (the list of strings).

To advance the day count and dayOfWeek automatically you could modify your tick function to make the changes when time rolls over/past to the first period. This works for the case where the character parties until dawn.

It needs some care though if the character starts an activity late at night as the day might roll over before they choose to sleep. All date/time implementations get a little tricksy if you allow activities where the PC’s sleep cycle gets decoupled from the day/night cycle. This is why I made rolling the day/dayOfWeek optional in my original version. Your life will be simpler if you avoid this happening, but it may be inevitable depending on your scenario (In Tramp the PC’s midnight snacking is one place this occurs: the day has rolled over, but they haven’t finished sleeping yet).

So this whole block becomes (with rolling day/dayOfWeek):

init python:
    def tick(amount=1):
        global day, dayOfWeek, time, time_map, timestr
        time += amount
        if time > len(time_map) - 1:
            day += time // len(time_map)        # Advance day
            dayOfWeek += time // len(time_map)  # Advance day of week
            dayOfWeek %= len(daysOfWeek)        # Wrap day of week back to Monday
            # dayOfWeekStr = daysOfWeek[dayOfWeek] # update if you are using this
            time %= len(time_map)     
        timestr = time_map[time]

    def isWeekday():
        return dayOfWeek <= 5

    def isWeekend():
        return dayOfWeek >= 6

At the end of each activity you just use the appropriate number of ticks, usually one, but could be more. The day and dayOfWeek will change at midnight.

It can be useful when implementing sleep to have a function that goes to the start of the next day. This is the nextDay function I originally had. Without it you have to work out how many ticks to add to roll the day over.

label sleep:
    "You curly up in bed and are soon asleep."
    # $ tick(len(time_map) - time)   # You have to do this without the nextDay function
    $ nextDay()
    # Reset player energy if you are tracking that
    "Your alarm is going off before you know it. It's a fresh new day."
    jump main

For after those all-night parties you may want this instead:

label daytimeSleep:
    "You really need some sleep, so you flop into bed exhausted."
    $ tick(2)   # Maybe 3?
    # Reset player energy if you are tracking that, possibly not the full amount?
    "You wake up later the same day."
    jump main

This might be the result of an un-closed “{size=-2}” text tag or similar thing that modifies the text size.

Hey thanks for the advice again! I’m going to try and test out the time ticking and day passing ASAP as soon as I write at least one scenario, but first uh… any idea why, using your stuff above, work and school are appearing on a sunday? What do I need to write to make those events weekdays only (mon-fri)

First up, my bad, I got the numbers wrong, these should be:

    def isWeekday():
        return dayOfWeek <= 4    # Mon thru Fri

    def isWeekend():
        return dayOfWeek >= 5    # Sat, Sun

In your menus your conditions need to look like:

    menu:
        "Work" if isWeekday() and (time == 1 or time == 2 or time == 3):

The and operator is of a higher operator precedence than the or operator, much like */ are higher precedence than +- in PEMDAS/BODMAS. So brackets are needed to apply the weekday test to all the times. There’s a full list here: Python operator precedence

If you had:

"Work" if isWeekday() and time == 1 or time == 2 or time == 3:

You are saying show the option at time period 1 on weekdays, or at time period 2 or 3 on any day.

As an alternative, if you are comfortable with it, you can also go “full Python” and write:

    menu:
        "Work" if isWeekday() and time in [1, 2, 3]:
1 Like

Hey thanks so much! I’ve gotten it working now where it only shows them at the right time and day, I think!

Now, I need to figure out how to make it semi-randomly pick between multiple potential events for each thing, so that it isn’t the same exact scene at the gym everyday every hour.

EDIT: So, what would I need to do to make it so it seamlessly transitions to day 2?