CreatorsOk
vrengames
vrengames

patreon


The problem with Rollback.

v0.4.0 is out for $5 patrons, and I'm hard at work fixing up all the bugs that are cropping up for the v0.4.1 public release.  

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!

Comments

yup, renpy documentation is terrible for doing anything bigger than a toy project. Took me ages to figure this out as well.

Waiting for Public Release, Mom and sister scenes are so fucking hot btw

BlueJun

Fixed up, this will be included in the v0.4.1 update in a few days.

Vren

You can now reach either purple or red without the other one, although both now require Stephanie's help in the lab to create.

Vren

Vren, will there ever be minor influence gains through actions? It's not exactly necessary, but I was wondering for the sake of actions without using serum like taking Alexia to lunch/coffee or movie night with the mother and/or sister. Like 1-3 influence gained (or lost if resisted) for actions taken.

Cyril Vaxx

Hey, I found a bug in the 0.4.0 release: On evening 11, I ask Nora about chems. The game throws an exception, saying that "nora_slut_score" [line 4738 in script.py] is undefined. I changed it to noraO.slut_score and things seem to be working (so far).

Gmeng

does it have to now deal with influence as well like if stephanie infulence is low you can't make the purple

Jonathan Heard

the option for the purple serum seems to not appear like i can make the red first and not the purple

Jonathan Heard

I couldn't stop thinking about this, so I spent the night digging around and finally figured it out! Classes need to inherit from renpy.store.object to roll back properly, despite most of the documentation suggesting it should work automatically.

Vren

You'll need Stephanie's help now to produce purple serum, and you'll need three doses of blue serum in addition to serum supplies to make it.

Vren

did the research for the german team and can't seem to unlock the purple serum and i know in the previous version you could make solo

Jonathan Heard

It should work fine if you move all your calculations either to the decision tree, the line immediately following the decision tree, or just before the event ends. Alternatively, you can save the change to a global temp variable, like TempSisRes = -10, and continue using them on the lines where the changes would intuitively be, followed at the end of the event with sisO.resistance_score += TempSisRes. Unless rollback is meant to go back further than just the most recent decision, in which case neither of these would work. I think I've edited this comment like 5 times now as I keep thinking of how things might work if done one way or another. I'll go grab a copy of ren'py and play around with it for a bit.


More Models and Creators