Renpy saving issue - not saving after chapter menu.

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
User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Renpy saving issue - not saving after chapter menu.

#1 Post by ChroniclerOfLegends »

Hello, hopefully I am asking in the right place. This is my first post here.

I have been able to figure out quite a lot already on my own using this forum and the documentation, I have got to say I love how simple it is to code with renpy!

On to my actual problem:

I have quite a few features added and working happily to my game, but somewhere along the way I have broken the ability to save correctly.

Background on the game I am making:
I want a non-linear story, and the way that I planned to do this was instead of chapter1 jumping to chapter2 and etc. I would have flags that unlocked as you went.

So complete chapter 1 and you get access to chapter 2 and side story 1 and side story 2. side stories are not required to complete the game, but they may be fun chapters to get to know certain characters better (and unlock more side stories) or minigames etc.

How I have implemented this so far, is by setting flags in chapters that you play through. When you complete a chapter, it returns you to a chapter select menu where you can pick where to go next, with more options unlocking as you play.

My problem is that saving breaks after opening this chapter select menu. You can save fine all through prologue (which you are started on to give basic character info such as name/gender etc.) After the prologue, I use jump to get to chapter 1, and make the chapter menu accessible from the quick bar. The chapter menu opens when you either complete chapter 1, or select it from the quick bar. This is where the problem starts. If you complete chapter 1 and are automatically taken to the chapter select screen you can save correctly. If you select it from the quick menu, then no matter how far you play or what chapters you select it will save at the point during the prologue where you clicked the chapter select button from the quick menu, not where you actually are.

I have read through Renpy's documentation on jumps and calling, and on saving, and there is just something I am not understanding about how renpy chooses where to save. I have tried moving to labels using both 'call' and 'jump'. What's more, it behaves similarly if I 'return' from the chapter select menu. Whatever may have happened in between is lost and it returns to the first place I opened the chapter select menu.

The labels in my main script:

Code: Select all

label return_to_menu:
    nar "Return to the menu to select your next destination."
    #call screen chselect 
    call ship_menu # above commented out statement had the same effect.
    
label ship_menu:
    call screen chselect # The name of the screen displayed to select chapter
    nar "Please make a selection from the ship's menu."
    jump ship_menu
The button I added to the quick menu to access the screen:

Code: Select all

textbutton _("Ship Menu") action ShowMenu('yesno_prompt', 'End current scene and return to ship\'s menu? Progress in this scene will be lost.', [Hide('yesno_menu'), Jump('ship_menu')], [Hide('yesno_menu'), Return()])
The chapter select screen itself:

Code: Select all

##############################################################################
# Chapter Select
#
# Screen that allows the user to jump to a chapter

screen chselect():

    tag menu
    
    # The background of the game menu.
    window:
        style "gm_root"

    # Include the navigation.
    use navigation
    
    on "show" action Stop("text_bleeps")

    grid 1 1:
        style_group "chselect"
        xfill True

        vbox:
            # The left column.
            frame:
                style_group "chselect"
                has vbox
                
                label _("Current Credits: [current_credits]") # For displaying how much money you have.
            frame:
                style_group "chselect"
                has vbox

                label _("Missions")
                if persistent.prologue_unlocked:
                    textbutton _("Prologue") action [Hide('menu'), Jump('scene_prologue1')]
                if persistent.ch1_unlocked:
                    textbutton _("Chapter 1") action [Hide('menu'), Jump('scene_ch1_1')]

            frame:
                style_group "chselect"
                has vbox

                label _("Jobs")
                if persistent.job_asteroid_clearing_1_unlocked:
                    textbutton _("Asteroid Clearing 1") action [Hide('menu'), Jump('job_asteroid_clearing_1')]
                if persistent.job_debugging_unlocked:
                    textbutton _("DEBUGGING") action [Hide('menu'), Jump('job_debugging')]
                
init -2:
    style chselect_frame:
        xfill True
        xmargin 5
        top_margin 5

    style chselect_vbox:
        xfill True

    style chselect_button:
        size_group "chselect"
        xalign 1.0
and I end a chapter and go back to the menu by:

Code: Select all

# all 3 have the same effect it seems.
#jump return_to_menu
call return_to_menu
#return
Please ignore the 'ship_menu' thing lol. It is a scifi game where you are captain of a ship.

User avatar
PyTom
Ren'Py Creator
Posts: 16096
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#2 Post by PyTom »

ShowMenu starts running code in the menu context. You can't do a Jump in the menu context, since you stay there. The menu context doesn't participate in saving and loading, hence your problem.

It seems weird to jump to an arbitrary point from a menu, but if you really want to do that, Start("label") should work. (It's a nonstandard use, but Start really means "jump out of the menu context and to a label".)
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
Software > Drama • https://www.patreon.com/renpytom

User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#3 Post by ChroniclerOfLegends »

Thank you so much! That solved the problem and got it working exactly like I wanted it.

User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#4 Post by ChroniclerOfLegends »

Hello again, sorry for bringing this back up, but while saving is fixed it seems to have brought up another issue.

I didn't notice it at first because it works fine the first time you run through.
After you have returned from whatever scene you selected back to the chapter select menu, if you select another chapter renpy crashes with this exception:

Code: Select all

File "renpy/common/000statements.rpy", line 471, in execute_call_screen
    store._return = renpy.call_screen(name, *args, **kwargs)
  File "renpy/common/00action_menu.rpy", line 141, in __call__
    renpy.jump_out_of_context(self.label)
JumpOutException: job_debugging
I looked around at other posts and found someone with a similar issue. It seems that after using start to jump out of the menu context, that the second time when you go back to the menu there isn't an outer context to return to.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#5 Post by gas »

Don't use "ShowMenu" to show the confirm screen. Use the Confirm action.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#6 Post by ChroniclerOfLegends »

While changing that didn't help, I tried getting rid of the confirmation altogether since it isn't really necessary. That gets rid of the crash, but the game returns to the main menu at the point it was crashing.

Didn't see a confirm action in the documentation. Thanks for letting me know about it.

User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#7 Post by ChroniclerOfLegends »

Am I going about this a weird way? It seems like selecting a route using imagemaps is a popular way of choosing between different available scenes. I felt selecting from a menu made more sense and seemed an easier route to code for my game, like selecting destinations for your ship.

The only thing I can think could be causing the problem is that I want certain scenes to be replayable. (Mini-games which unlock things based on score).

I am trying to have a story with multiple branches ex:

(Intro) (Main Scene 1) (Main Scene 2) (Main Scene 3)
(Side Story A1) (Side Story A2) (Side Story A3)
(Mini game 1) (Side Story B1)
(Mini Game 1) ---> etc.

Where you unlock side paths by completing main story, and you unlock more of the side paths by completing them.
But the player has a choice whether to continue on in the main story or progress in a side path whenever they want.

User avatar
ChroniclerOfLegends
Regular
Posts: 53
Joined: Thu Feb 16, 2017 5:57 pm
Projects: Scifi Non-Linear Visual Novel/Arcade/Adventure game. (No name yet)
Contact:

Re: Renpy saving issue - not saving after chapter menu.

#8 Post by ChroniclerOfLegends »

Sorry for bumping this again, but I wanted to post the possible solution that I found in case anybody else runs into similar issues:

Forgive me if I explain any of this incorrectly, I am still fairly new to renpy, and the call stack and contexts are still confusing to me.

There were two problems that arose:
1) The game wouldn't save correctly because opening a menu and jumping to a new label would leave you in the menu context, so all that was getting saved was the events before opening the menu.
2) Using action Start() would take you out of the menu context and get saving working again, but using Start() on the same label more than once from the menu seemed to be messing up the return stack, as it would crash the second time you jumped to a scene.

The workaround as I have it now:
I noticed that the save games would be at the point where I called the chapter select screen. So instead of calling the chapter select screen immediately, I had the quick bar button just do a jump to a label that doesn't do anything but call the chapter select screen. That way, when the menu context is entered, it will at least push the label calling the menu into a call stack, so that when you load your save you are just returned to the menu.

I also changed the buttons in the menu back from Start() which was causing the crash back to Jump(), and added 'return' to the end of the scenes that can be jumped to from the menu.

To my surprise it seems to be working correctly now. Been trying to break it for about an hour, and so far it lets me save anywhere I want, even saving looking at the menu screen. I do not know enough to be able to explain this, but it works for me.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]