Page 1 of 1

Roll Forward doesn't restore a value

Posted: Wed Jan 08, 2020 5:56 pm
by yes
So here is a simple project code:

Code: Select all

default money = 0
default clicks = 0

label start():
    jump test

screen scr_pause():
    pass

screen scr_test():
    vbox:
        text "Money: [money]"
        text "Clicks: [clicks]"
        textbutton "I need money!" action [SetVariable('money', money + 100), Jump('test')]

label test():
    show screen scr_test
    $ clicks += 1
    call screen scr_pause
It shows a screen with a button that increases the "money" variable and jumps to some label (in this case the same label).
If I click it multiple times, then rollback (both values are rollbacked properly to their initial values), then roll forward, I don't get my money back (but "clicks" is changed properly).

Obviously, the difference is that "money" variable is changed from a screen, but I don't know if this behavior is intended or I'm missing something?
Is there a way to have the desirable behavior, when I can roll back/forward and restore a value changed inside a screen?

Re: Roll Forward doesn't restore a value

Posted: Wed Jan 08, 2020 6:58 pm
by rayminator
in preference there should be a selection says

I don't much only a little but I think it's because it's set to disable that it will not restore the variables back I'm just guessing on it but I might be wrong

disable -- set in default
rollback enable
rollfoward enable

Re: Roll Forward doesn't restore a value

Posted: Thu Jan 09, 2020 1:26 pm
by rames44
This is known behavior within a screen. The same thing happens if you save and restore within a screen.

The fix for saving is here: https://www.renpy.org/doc/html/save_loa ... after-load

But the critical fact for you is that rollback and roll forward are based on the same system as saving, and that those snapshots only get made at the beginning of each statement.

https://www.renpy.org/doc/html/save_loa ... n-py-saves

So since your “call screen” hadn’t finished executing when you rolled back, the screens internal state wasn’t saved.