confirming a save?

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
pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

confirming a save?

#1 Post by pucedragonlord »

My project has some extra behavior regarding saving, but I only want it to run when the player successfully saves the game. I put all the extra stuff on the save buttons, but I didn't take into account what happens when a player tries to overwrite a slot, and things break if the player says "no" there.

Is there some way I can fire off actions on the save screen only after the game sucessfully saves? Related, what, if anything, does the FileAction() function return, and under what conditions?
The more you know

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: confirming a save?

#2 Post by PyTom »

I'd suggest just looking at the code in renpy/common/00action_file.rpy. Your best bet would be just to clone FileSave and FileAction into your own actions.
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

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: confirming a save?

#3 Post by pucedragonlord »

Is there a way to go about that that doesn't involve copying every file-related action and accompanying code to the new file? I'm not 100% clear on how the init -x statements affect variable scope, but if I just want to make custom versions of FileSave(), FileLoad(), and FileAction(), what do I have to do to make them work outside of the 00action_file.rpy file?

Right now it just throws errors that variables haven't been defined. I'm sure just copying everything relevant over would work, too, but I figure I should see if there's a more elegant solution first.
The more you know

User avatar
PyTom
Ren'Py Creator
Posts: 16088
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: confirming a save?

#4 Post by PyTom »

Offhand, what do you need to do? I'll note that autosaves occur all the time.

(I'm trying to think if there's a good way to do what you want.)
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

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: confirming a save?

#5 Post by pucedragonlord »

The main thing I want it to do is remember which save file the player last manually saved to or loaded from. The whole game runs in a dynamic loop that puts each page together (it's got a nvl mode structure, as opposed to the standard one), and at the beginning, if the player has certain options selected, the game automatically saves over that recorded save file. There's a roguelike mode, too, that deletes the active save on death, which also needs to know which slot to delete. I tried using the built in last-save function, but that mostly ends up referring to the standard autosaves.

Ideally, I'd like to be able to close the save menu on a successful save, too.

I tried tying these to the save slot buttons, but things break if you try to overwrite a save and say "no" when prompted.
The more you know

pucedragonlord
Regular
Posts: 159
Joined: Wed May 09, 2012 2:49 am
Projects: The Diviner
Organization: Two Crowns Entertainment
Location: Now: Charlottesville, VA
Contact:

Re: confirming a save?

#6 Post by pucedragonlord »

Alright, well, when I include all the other file actions in the new file, I can make most things work, but I'm still unable to automatically close the game screen after the game saves.

I tried putting a

Code: Select all

if condition:
    return
between the

Code: Select all

renpy.save(fn, extra_info=save_name)

renpy.restart_interaction()
in the FileSave action (or rather my edited copy of it), but it doesn't do anything. I tried the action (Return()) version, too, but that didn't work either. I feel like I'm forgetting some basic syntax here, but cannot recall the proper way to do it or find an example in my existing code.
The more you know

Post Reply

Who is online

Users browsing this forum: piinkpuddiin