Best strategy for saving games to accomodate future versions?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
AVNSnax
Regular
Posts: 79
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Best strategy for saving games to accomodate future versions?

#1 Post by AVNSnax »

I know this is a common problem and I've seen lots of VNs handle it different ways. I'm looking for suggestions for the best strategy.

I'm in the middle of building a VN that will have 10 chapters in total. I'd like to release the first two chapters, but am at a loss as to how to prompt the user at the end of the current content to save the game so that they can just load into the next chapter when it becomes available.

Putting up a screen prompting the user to save is easy enough, but when the saved game is loaded it tries to load the prompt screen itself (which I'd like not to appear in the next version). I guess I could say "back up to the previous screen and save" but that seems very inelegant to me. Accumulating a bunch of version-specific labels and code to handle future chapters also seems a bit extreme. I could programmatically generate a special save, I guess, but that also seems wrong.

How do you experienced Ren'Py authors handle this? Thanks!

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Best strategy for saving games to accomodate future versions?

#2 Post by zmook »

The save file includes the rollback buffer. If renpy tries to reload a game and finds the expected "current line" no longer exists, it should automatically roll back until it finds a line that *does* still exist. So really, all you need to do is change the "hey, this is a good time to save" line so that renpy no longer recognizes it (either change the words, or delete it from the end of your "chapter2.rpy" file and move it to the end of "chapter3.rpy") and it should pretty much just do what you want.

Or do I misunderstand?
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
AVNSnax
Regular
Posts: 79
Joined: Sun Feb 06, 2022 12:11 am
itch: avnsnax
Contact:

Re: Best strategy for saving games to accomodate future versions?

#3 Post by AVNSnax »

zmook wrote: Fri May 27, 2022 6:37 pm The save file includes the rollback buffer. If renpy tries to reload a game and finds the expected "current line" no longer exists, it should automatically roll back until it finds a line that *does* still exist. So really, all you need to do is change the "hey, this is a good time to save" line so that renpy no longer recognizes it (either change the words, or delete it from the end of your "chapter2.rpy" file and move it to the end of "chapter3.rpy") and it should pretty much just do what you want.

Or do I misunderstand?
It's not been entirely consistent for me. I've gotten into a couple of situations where trying to load the saved prompt screen just results in an endless loop, presumably as the rollback tries to find some place to land. I should add that I've added a couple of changes to the VN before the location of the save, but nothing involving variable changes so it should be safe? The other issue is trying to call labels that have already been accessed (i.e. sandbox locations) sometimes causes a crash.

It's not consistent which is the frustrating bit. My first test was to just repeat a call to chapter 1 (with a unique from statement) and renpy wasn't having any of that. Endless loop crash. I copied and pasted lines from chapter 1 right into the code and that worked fine.

I guess I just need to test some more.

User avatar
zmook
Veteran
Posts: 421
Joined: Wed Aug 26, 2020 6:44 pm
Contact:

Re: Best strategy for saving games to accomodate future versions?

#4 Post by zmook »

Ren'py uses the .rpyc files when rolling back, so if you've deleted and rebuilt those, you can get "can't find a place to stop rolling back." It's a little fragile, so there are other things that can mess with it, not sure if I can properly enumerate them. But we don't need to know, really, because all we need is one statement that is guaranteed always to get the same name no matter what you do to its source file, and that is the "label" statement.

So if you do something like this:

Code: Select all

label end_chapter_2:
     scene black
     "end of current content, please save your game now"
when you release a version, then change it to:

Code: Select all

label end_chapter_2:
     scene black
     jump start_chapter_3
it should be pretty consistent. (See https://patreon.renpy.org/rpyc.html)
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM

User avatar
m_from_space
Miko-Class Veteran
Posts: 949
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: Best strategy for saving games to accomodate future versions?

#5 Post by m_from_space »

I would do something like this for every new chapter that's not already existent, but then it will be:

Code: Select all

default after_chapter_1 = "end_game"
default after_chapter_2 = "end_game"

# this is a special renpy label
label after_load:
    # if you now finished building chapter 2 for the players
    $ after_chapter_1 = "chapter_2"
    # if you have finished chapter 3 etc.
    # $ after_chapter_2 = "final_chapter"
    
label chapter_1:
    "This is chapter one."
    jump expression after_chapter_1
        
label chapter_2:
    "This is chapter 2."
    jump expression after_chapter_2
    
label end_game:
    "The game ends for now."
    return

Post Reply

Who is online

Users browsing this forum: No registered users