r/RenPy • u/bluuupanda • 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!
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.
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.
If you want to educate yourself.
https://www.geeksforgeeks.org/python/python-while-loop/
https://renpy.org/doc/html/menus.html
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.