Adding a TL;DR since this is kind of long and probably a little confusing. Basically, I'm having a ton of problems getting a chapter select to work the way I want it to. If you think you have an idea for how to get this working, you don't need to read the entirety of the rest of this thread, although I would appreciate at least a skim so you can see whether or not I've tried your suggestion already.
How I want it to function: (stuff that I can't seem to get working right will have a red asterisk)
- From the main menu, the player can either choose to enter each route directly where they left off or go to chapter select for that route*
- From the chapter select menu, the player can select any chapter to play, but only if they are not currently inside a chapter already (if the leave the game in the middle of a chapter, all other chapters are greyed out except the one they are on until they finish the one they are on)
- Players can leave the chapter at any time during a chapter and come back to the chapter in around the same spot they were before in that chapter without having to restart the chapter entirely*
- When finished with one chapter, players can choose to either continue to the next chapter or exit back to the chapter select menu*
- If the player chooses to exit the chapter, they can go back and replay any of the previous chapters they've already unlocked, and this will overwrite any variables they've modified, without getting rid of their progress*
- Variables modified in one chapter should continue to have that modified value in following chapters*
- Players have only one save per route. There is no save slot menu, saves are handled automatically.*
- All these things should be true at the same time, without any of them causing problems with any of the others************
Below is a documentation of my struggles: (i.e. tl;dr is now over)
Hi!
I've mentioned this in some other posts I've made, but my game has a particular set up where players select a route on the main menu, and each route has a "start/continue" button and a "chapter select" menu button.
The Start/Continue button checks to see if an autosave with the character's name as a prefix exist (for example, "[charactername]-auto-1". To make this work, I have an autosave prefix callback that changes the autosave prefix depending on which character route you're playing, and I have the maximum number of autosaves set to 1.)
The Chapter Select button, meanwhile, checks to see if a save file exists with the name "[charactername]menu" (where charactername depends on which route you're trying to view the menu for), and if it exists, loads that save file, and if it doesn't, jumps to a label that shows the menu screen for that character. The Menu save file is saved right before the player exits out of the chapter select menu to go to the main menu.
The reason I have the character menu screen shown inside a label rather than as a screen on the main menu is because I need to make it so that players can exit out of a chapter at the end of it, and start the next chapter from the chapter select menu without needing to store variables from the previous chapter as persistent data. I set it up this way on the suggestion of another user here, you can see that topic here to get a better idea of what my end goal with this setup is.
Here is the code for my start/continue and chapter select buttons:
Code: Select all
# variables that detect if either respective save file exists
default menufileexists = FileLoadable(char + "menu",slot=True)
default gamefileexists = FileLoadable(char + "-auto-1",slot=True)
## Start/Continue button
# if there's no menu file (which there should be if the player has made any game progress) the button should say "start" and start from the route beginning
if not menufileexists:
textbutton ("START"):
style "routestartbutton"
text_style "startbtntxt"
action Start(char + "_chap1part1")
else: # if not, the button should say continue and load the game file
textbutton ("CONTINUE"):
style "routestartbutton"
text_style "startbtntxt"
action FileLoad(char + "-auto-1",confirm=False,slot=True))
## Chapter Select button
# checks if a menu file exists, and if it doesn't starts the game from the appropriate menu label
textbutton ("CHAPTER SELECT"):
style "routemenubutton"
text_style "routemenubuttontxt"
action If(menufileexists,FileLoad(char + "menu",confirm=False,slot=True),Start(char + "_menu"))
xalign 0.5
Code: Select all
## This is a header that is shown on both the chapter select screen and during gameplay. during gameplay, it collapses to be unintrusive, but a button in the corner can be clicked to slide it down and do things like exit, save, view game settings, etc
imagemap:
## this code determines whether the header is collapsed or not. Header cannot be collapsed unless the player is inside gameplay
if ingame == False:
auto "gui/mainmenu/header_%s.png"
elif headerclosed == True:
ground "gui/mainmenu/bx_header_story.png"
hover "gui/mainmenu/bx_header_story.png"
at slide_up
else:
auto "gui/mainmenu/header-story_%s.png"
at slide_down
## this code determines what the header's exit button will do depending on if you are inside a chapter or on the chapter select screen
hotspot (32,27,85,50):
if ingame == True:
## if player is inside a chapter, the exit button takes the player to the chapter select menu
action [SetVariable("ingame",False),Jump(savefilename + "_menu")]
sensitive headerclosed == False
else:
## if the player is already on the chapter select menu, save the game to the "[charactername]menu" save slot and then exit to the main menu if successful
action FileSave(savefilename + "menu", confirm=False, slot=True, action=MainMenu(confirm=False))
My problem:
Frequently I find that if I exit out of the game in the middle of a chapter, (particularly if I load an existing autosave for a chapter via the chapter select menu and then immediately exit) then exit out of the chapter select menu to the main menu, what happens is that if I click the "Chapter Select" button again, instead of loading the menu save and showing the chapter select menu, it will load the autosave, and take me directly back into the chapter I was just playing. (i.e. the Chapter Select button is performing the function of the Start/Continue button in these cases for some reason)
Most of the time, loading the chapter select works as intended, even when there is an autosave file. But sometimes it just decides to load the autosave instead of the menu file for whatever reason. I can't seem to figure out why.
I need to find a way to fix this. This "separate save for in-game and menu screens" set up is the only way I can think of to make my chapter select work the way I want it to without storing every single important in-game variable throughout the route as persistent data, but it's honestly getting so frustrating trying to get it to work that I'm considering just saying "fuck it", abandoning dealing with renpy saves, and doing it the persistent data way.
(As a sidenote, I see a lot of experienced Ren'Py users on here complain about more inexperienced users relying too heavily on persistent data, but it's things like this that really makes me sympathize with those inexperienced users. The Ren'Py save system is designed in such a limiting, difficult to use way that expects your game to conform to it's own idea of what a visual novel's save system should look like, and if you want to deviate from that mold even a little bit, it's so difficult that it's honestly easier to just abuse persistent data)