[SOLVED] Saves loading in the wrong place?

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
asylumsweetie
Regular
Posts: 31
Joined: Sun Mar 31, 2013 2:37 am
Contact:

[SOLVED] Saves loading in the wrong place?

#1 Post by asylumsweetie »

I have no idea how to track the cause of this problem down or even how to google it. No matter where I am in the game when I save, when I load it I will always be at the beginning of scene 2, the second label in the script file. Any time I use the rollback or reload function, it also puts me back at the beginning of scene, and sometimes even just using the "back" button. Variables and such also aren't preserved, it isn't just jumping to the wrong label, it completely undoes any progress since the first time I reached that point in the game. It's making testing a real pain in the ass! When I start the game without loading a save it plays normally, I just can't load a save. I haven't touched anything in the options file or anything else that I think should affect that. I don't even know what code to show you here because I don't want to dump the whole game and I have no idea what section could be causing this.
Any ideas?
Last edited by asylumsweetie on Tue Jul 13, 2021 7:01 pm, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3785
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Saves loading in the wrong place?

#2 Post by Imperf3kt »

First thing I would do is try the "clear persistent data" button in the launcher before test playing your game followed by the "force recompile" button.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Saves loading in the wrong place?

#3 Post by strayerror »

What you describe sounds like what you'd expect to occur if you entered a new context at the beginning of (or just before) scene 2. Secondary contexts don't participate in saving, so when creating a save from inside one it ends up being like saving right before the context was entered (but it will still use what's currently displayed for the thumbnail). That's not exactly something done accidentally though, so only worth considering if you already know you're doing strange things with contexts.

asylumsweetie
Regular
Posts: 31
Joined: Sun Mar 31, 2013 2:37 am
Contact:

Re: Saves loading in the wrong place?

#4 Post by asylumsweetie »

I'll try clearing persistent data and forcing recompile and see if that helps, but strayerror may have figured it out.

I don't know anything about contexts tbh but part of the inventory code I'm using uses "call in new context" when you use an item. I only have one item that's usable at this point and you're supposed to use it in scene 2 to progress to the next part of the game. So I need to figure out how to I guess leave the new context created by using the item and go back to the original? I'll look up contexts and see what I can figure out.

EDIT: I read the renpy documentation on contexts but it is really frustratingly vague as usual. I think renpy.jump_out_of_context() is what I need. I've plugged it in and it seems to have fixed the problem! Gonna call this tentatively solved for now.
For anyone curious, I basically set up a variable based routing system. Whenever the player enters a scene where the inventory is accessible they get a variable called for example scene2(and any other scene variables are turned off), and if they go into the inventory, when they close it they get shunted to a label called scenedecider which is just a series of if statements that checks for which scene variable is active and sends them to the beginning of that scene. It's probably way more clunky and elaborate than necessary but hey it works.

Code: Select all

##############Scene Decider##############################

label scenedecider:
    if scene2 == True:
        $renpy.jump_out_of_context("v2scene2")
    elif scene4 == True:
        $renpy.jump_out_of_context("v2scene4")
    elif scene6 == True:
        $renpy.jump_out_of_context("v2scene6")
    elif scene10 == True:
        $renpy.jump_out_of_context("v2scene10")
    else:
        $ MainMenu(confirm=False)()


Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]