Is it possible for the game to close while saving the last logged / saved file, so that when the player enters the same file, something different happens?
Example: The player enters file 2 and a "restart to continue" message appears. After this message, the game returns to the home menu. The player selects file 2, and other things happen, things that would continue the game.
That's confusing :dizzy: what are you trying to do???
You can add more code in Scene_Save's def on_savefile_ok to to force players back to title screen.
def on_savefile_ok
super
if DataManager.save_game(@index)
msgbox("Restart to continue")
Sound.play_save
SceneManager.goto(Scene_Title)
else
Sound.play_buzzer
end
end
The reason you can't save (easily) from the title screen is that the save system assumes the game state is loaded when it does a save. Once you've left the map and returned to the title screen, much of the important state you'd want to put into your save file has already been lost.
That said, there's only a small number places where the player can actually return to the menu from a code PoV (presuming you don't care about clicking the close button in the windows UI), so putting a 'save now' command there would be fairly easily (as Roninator le Deux said).
I'm sure this is top of mind for you, but if you do automatically overwrite a player's save state, make sure they understand you're doing that. If you have an explicit save model, but also just randomly overwrite a player's save state with other stuff, it can be frustrating and disorienting for the player. Another option would be to serialize into a custom auto-save slot, or something like it. That way, the players' manual saves are sacrosanct, but you can still write out your save-on-quit stuff. It's not all that hard to save or load from any random filename in the saves dir, using code.
Obv, I don't know what your intended use is, so take that all with a grain of salt 🙂