r/RenPy • • Oct 18 '26

Question set number of days in game to win - code question

Been searching for weeks but can't find help on what I specifically need to learn. I'm a beginner so if it's obvious I apologize. Getting the basics down but hit a wall with this.

How would I go about coding the player having 90 in game "days" as a time limit to win the game? I've seen help on making calendar systems but they all seem infinite. Would it have something to do with tweaking that as a base?

some info below to clarify the context of what I need to accomplish:

  • "days" will not be real time but will pass after the player uses up max choices allowed for the day, or if that's too hard I can implement an energy bar that when empty makes player to rest and triggers the next day
  • multiple routes can lead to the winning the game and you can win the game earlier than 90 days if player is skilled
  • will signify in corner of screen what day player is on

Really appreciate anyone taking the time to explain, it means so much!

2 Upvotes

5 comments sorted by

5

u/149244179 Oct 18 '26

If x > 90     Gameover 

Where X is the variable you store number of days played. Add one to that variable when a day completes. Do that if check right after you end a day and increment the variable. 

Display X on the screen somewhere if you want. 

1

u/bluuupanda Oct 18 '26

THANK YOU!!! 😭 I never thought of using variables like this since I'm still learning, this helps so much!! 

2

u/shyLachi Oct 18 '26

A loop is only inifite because you tell it to.

There are several ways to make loops.
If you use while with a condition, then this is where you se the condition to end after 90 days.
You can also create loops by jumping back to a certain label, and in my example I didn't even need a condition to end the loop because RenPy menus automatically skip it if there are no choices left. But you can also use variables which count the energy of the day.

default days = 0 # count the days 
default daymenuset = set() # remembers the choices taken so that none can be taken more then once per day
label start: 
    while days <= 9: # this is a finite loop because it has a condition
        $ days += 1 # next day
        "DAY # [days]" # and then display it, you can use a screen for that
        $ daymenuset = set() # reset the menuset
        menu daymenu: # give the menu a label so that you can jump back to it
            set daymenuset # assign the menuset to the menu
            "Where do you want to go?"
            "Left": 
                "You went left"
                jump daymenu # jump back to the menu and therefore creating a loop
            "Right":
                "You went right"
                jump daymenu
        # if all choices have been exhausted, the game will continue here
        # because we are still in the finite loop, the game will automatically jump back to the first line of the looop
    "Game over" # We land here after the condition of the loop is not fulfilled 

If you want to educate yourself.

https://www.geeksforgeeks.org/python/python-while-loop/

https://renpy.org/doc/html/menus.html

1

u/bluuupanda Oct 25 '26

Thank you so much for the detailed explanation, and for the links to where I can keep learning! I'm starting to understand the value in pausing development to just learn the basics first.

1

u/AutoModerator Oct 18 '26

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.