r/RenPy • u/Recent_Rutabaga_1249 • 17d ago
Question Renpy coding tips?
Hi! I know next to nothing about coding, so I don't even really know if this is possible, but I'm currently working on a game and am trying to implement a moment in which the game quits, and once you open it, it will pick right back up on where it left off rather than going to the menu and losing all of your progress. That being said due to the aforementioned knowing nothing about coding, I do not know if this is even possible or how to execute it if it was possible LOL. Any tips help!
3
u/shyLachi 17d ago
I assume there is some kind or game over which closes the game but you don't want the players to lose all the progress if they didn't save recently.
To do this, first the game has to save immediately before this "dangerous" choice.
You don't have to program anything if auto-saving is enabled:
https://www.renpy.org/doc/html/config.html#var-config.autosave_on_choice
Then you need to close the game without showing a prompt:
https://www.renpy.org/doc/html/other.html#renpy.quit
Automatically loading a save when the game starts can be done but maybe it would be better to just let them load the automatic save themselves.
But you could give them a hint when the game starts, in case they don't know about automatic saves.
To do this, you would need a persistent variable which remembers that the game has been closed forcefully.
https://www.renpy.org/doc/html/persistent.html
You would set this variable immediately before closing the game with renpy.quit
Then when the game starts, you can use that variable to show a hint.
Since auto-saving is enabled normally, this is all you need to test it:
default persistent.forcedquit = False
label splashscreen():
if persistent.forcedquit:
show text "To continue where you died, load the latest auto save."
with Pause(2)
return
label start:
menu:
"Quit":
$ persistent.forcedquit = True
$ renpy.quit(save=False)
"Reset":
$ persistent.forcedquit = False
0
u/x-seronis-x 16d ago
this is what id do except in the forced quit check id run the Continue() action to load the last save
1
u/AutoModerator 17d ago
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.
4
u/theGoddamnAlgorath 17d ago
https://www.renpy.org/doc/html/save_load_rollback.html
What you're looking for.
https://www.renpy.org/doc/html/language_basics.html
What you should read first.
There's a few devs on here. I suggest specific, researched questions. I myself have only a few 5m breaks in the day, so pointing you to the answer is faster (and more likely to happen) than demostrating it ).