Ren'Py Modding a sandbox game into a VN, save files load from the last "label" entry in the script, not from the screen they were saved at.

Heisenberg867

Newbie
Jul 18, 2018
90
149
As mentioned in the title, I'm modding Cure My Addiction (complicated sandbox) into a much more straightforward VN with a different story. I have made an enormous number of structural changes to the underlying code, and everything still works surprisingly well...except this.

I have the story script files broken down into Prologue, Chapter 1, Chapter 2, etc., each one with a label heading at the top of the file. What's happening is (e.g.) that if I save halfway through Chapter 1 and then try to load that save, it'll load the beginning of Chapter 1.

If I try to load from a location after (I suspect) too many lines of code have accumulated without a label line, Ren'Py throws an error I've never seen before: "Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?"

Thanks in advance. I've already tried making a fresh build, but frankly this has become such a kludgefest that starting from scratch causes about a dozen other problems that I have no energy to solve at this particular juncture.
 
  • Like
Reactions: Hadgar

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,581
2,219
In the options.rpy file, change the line define config.save_directory = {dirname} to something else.

If I had to guess, you're loading save games from the sandbox version into your more linear rewrite. RenPy is trying to figure out where the line of code has moved to and is unable to figure it out properly due to the sheer number of changes you've made.

RenPy doesn't save by label:. It saves the whole history of recent goings on within the game and the state of each of the variables as they change. It's also really good at matching lines where only a minor change was made (like changing "She looked up" to "She looked up.") It also (and I'm hazy on this one) has a tree structure type voodoo way of keeping track of the line being executed... so when you add a couple of lines into an existing game... it can still figure out where it's up to.

Essentially, when you load, it loads the whole history buffer and tries to match the line it was currently on. If it can find it, that's where it starts. If it can't figure out a close enough match, it goes back one history line and tries again. It keeps going back until finds a line it is comfortable enough being sure is a match. If the code has change so significantly that it can't find a match when it reaches the top of the history buffer... that's when it throws the error your seeing. Of course, it's not that simple.... I'm sure it's not just checking 1 single line at a time... but my explanation should be close enough to keep you on track.

By changing the default directory name for save files... you're effectively starting again from scratch and avoiding save history that is so radically different between the two versions.
This won't help much though if you're rewriting the code on the fly and saving in the middle of "old" code and then rewriting it and trying to load using "new" code. My suggestion is to starting thinking of them as two completely separate games (which they are) and slowly copy and paste dialogue from the original game into your new version of it.
 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,490
7,035
As a follow-up on what 79flavors said, PyTom published an article a while back on the innards of RPYC files. It's worth a read, primarily because there's a section called "Implications for Save Compatibility" that's worth understanding when you're modifying your game code release-to-release.