Roll Forward doesn't restore a value

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
yes
Newbie
Posts: 1
Joined: Wed Jan 08, 2020 5:00 pm
Contact:

Roll Forward doesn't restore a value

#1 Post by yes » Wed Jan 08, 2020 5:56 pm

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?

rayminator
Miko-Class Veteran
Posts: 754
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Roll Forward doesn't restore a value

#2 Post by rayminator » Wed Jan 08, 2020 6:58 pm

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

rames44
Veteran
Posts: 232
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Roll Forward doesn't restore a value

#3 Post by rames44 » Thu Jan 09, 2020 1:26 pm

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.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], span4ev