The problem with Rollback. (Patreon)
Content
One of my patrons noticed that in the new release there are a number of different places that prevent you from scrolling back and reverting your decision. I wanted to take a moment and explain why in depth because I found it kind of interesting.
Renpy includes a feature called Rollback, which allows the user to undo recent decisions and move back a few frames in the game. This is great if you accidentily click past some dialog you wanted to read, click the wrong option in a menu, or want to go back and appreciate some of the previous art. I think this is a great feature, but it's caused some problems.
First, lets look at how Rollback is done. Renpy keeps track of what variables change at each new screen, and undoes those changes if the user wants to roll back. Only keeping track of the changes means they aren't archiving all of the variable information each time you advance and makes it very quick and efficent to move backwards and forwards through the game. Rollback does not, however, play nice with objects.
A quick explanation of object oriented programing for non-programers: An object is a way of organising variables and functions in a program in a way that allows them to be created, modified, and destroyed independent of eachother. This makes the code much easier to maintain, because it only has to be changed once in each class. 0.4.0 moved each girl's stats, random events, major scenes, and minor scenes into their own objects. This made updates to the code vastly easier, and let me impliment the new serum system and the new random event system that we're now enjoying.
But here's the problem. Renpy only saves variables when they change from line to line, and changing a variable inside an object is not seen as a change to the object itself, so the object isn't saved. So if I have an object called sisO and do sisO.resistance_score += 10, then roll back to the previous line Renpy doesn't realize that the variable has changed and doesn't revert it. resistance_score stays at 10, and when you click forward again it gets raised by another 10.
This means any values that are changed within objects can't be rollback safe, because the user could scroll back and forth past them, changing values multiple times. I'm currently looking into ways to make objects rollback safe, but until I find a satisfactory solution I've had to put a rollback block on each function call that changes a value in an object.
tl;dr: Renpy's Rollback feature doesn't play well with objects, but objects are needed to do complicated things in Lab Rats. I'm looking into solutions, but for now rollbacks get blocked in certain places to prevent everything from breaking.
EDIT:
This has now been fixed, and rollback is working perfectly again! After writing this post I found I couldn't just let the problem rest, and I've spent the whole night digging through forum posts and ren'py documentation to see what I could do to fix it. It turns out that by default classes work as described above and are not rollback safe. However, if they inherit from renpy.store.object and contain only rollback safe variables or data types they'll work perfectly with rollback, reseting values as expected.
It was a little annoying to have to do so much digging to figure this out, and most of the documentation actually seems to either ignore or contradict this. The web page for ren'py save/load/rollback specifies a class that you inherit from if you don't want it to roll back, even though that's the default behaviour, doesn't mention anything about store.object, and suggests objects should rollback properly by default . Strange to say the least, but at least it's working now!