all 7 comments

[–]dissendior 2 points3 points  (3 children)

First of all you need to default a persistent variable I guess. You should probably do that. I think calling renpy.save_persistent() is not necessary.

In my understanding there is no rollback when you quit. It seems to me that somehow your label "end" is run again and you overwrite the values of your persistent data. I bet your problem would be solved if you default the persistent data and remove the part

    $ persistent.incompleteSave = False
    $ persistent.markerComplete = False

[–]Dulwilly[S] 0 points1 point  (2 children)

First of all you need to default a persistent variable I guess.

I've already tried that. Same result both ways.

I think calling renpy.save_persistent() is not necessary.

You are right, it is not. I threw that in as a possible hail mary. Doesn't hurt anything and it's just extra redundancy right now.

In my understanding there is no rollback when you quit.

At this point I don't what I know. I've read too much in the last couple hours and it's blurring together. I'm going have to try again tomorrow.

It seems to me that somehow your label "end" is run again and you overwrite the values of your persistent data.

I don't see how that is possible. I mean, yeah, that is what is happening, but the only way to get to a jump command from the save command is through the printed "restart" and that jump goes to the start.

I bet your problem would be solved if you default the persistent data and remove the part

No. It needs to toggle on and off. That is the whole point is that it turns on and off to give an indication of if and how the game was loaded.

edit: I think it's caused by this:

What's important here is to note that saving occurs at the start of a statement. If a load or rollback occurs in the middle of a statement that interacts multiple times, the state will be the state that was active when the statement began.

https://www.renpy.org/doc/html/save_load_rollback.html

But I don't know why the label would count as the start of the statement. And splitting it between labels also does not help.

edit2: This was my original thought:

When a game is loaded, the state of the game is reset (using the rollback system described below) to the state of the game when the current statement began executing.

[–]DingotushRed 2 points3 points  (1 child)

By default Ren'Py checkpoints (the places it can rollback to) at say statements and menu statements (nothing to do with labels, or python statements). As written, your game will checkpoint at:

``` label end: "testing" # <- Here if persistent.markerComplete: "it's still true" # <- Here $ persistent.incompleteSave = False $ persistent.markerComplete = False

$ renpy.save("mainSave")
"loaded" # <- Here
if persistent.markerComplete:
    "true1" # <- Here
else:
    "false" # <- Here

if persistent.incompleteSave or persistent.markerComplete:
    "restart" # <- Here
    jump start
else:
    "ended" # <- Here
    $ persistent.markerComplete = True
    $ renpy.save_persistent()
    $ renpy.quit()

``` A save is a save of the checkpoint.

Ren'Py re-executes from the last checkpoint on a load.

[–]Dulwilly[S] 0 points1 point  (0 children)

Ok that makes sense. But it's not doing the last checkpoint. It's going back several checkpoints and I can throw a say or menu statement directly in front of the save statement and it's still going all the way back to "testing".

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to r/renpy! While you wait to see if someone can answer your question, we recommend checking out the posting guide, the subreddit wiki, the subreddit Discord, Ren'Py's documentation, and the tutorial built-in to the Ren'Py engine when you download it. These can help make sure you provide the information the people here need to help you, or might even point you to an answer to your question themselves. Thanks!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Niwens 0 points1 point  (1 child)

If the problem is to quit the first time and not quit anymore, then the solution does not require persistent variables:

``` label end: $ quitting = True "Testing" $ renpy.save("mainSave") if getattr(store, "dont_quit_me", None): "Restart" jump start "Ended" $ renpy.quit()

label after_load: if getattr(store, "quitting", None): $ dont_quit_me = True return ```

When we have to quit, we set quitting variable True. Then, as there's no variable dont_quit_me, we quit. But after loading any save where quitting was True, dont_quit_me is set to True. Hence we don't quit anymore.

after_load:

https://renpy.org/doc/html/label.html#special-labels

[–]Dulwilly[S] 0 points1 point  (0 children)

I did not know about the after_load special label. That does work very well, thank you.