Page 1 of 1

Button to delete all save games & persistent data

Posted: Fri Oct 20, 2023 2:35 am
by Another_Tom
Sometimes you want to play a game from the beginning as if you never played it before, and what do you do? You delete each savegame by hand, click dozens of times to confirm, then navigate through various folders to delete the persistent files, and by the time you're done, half an hour has passed.
How about a text/image button that does this automatically?
(I didn't write the code myself just gathered it, it's all here in the forum).

Use this function with caution, if you hit the button all saves are lost aswell as persistent data.
Here's the python function which can be called by an action from a menu screen.

Code: Select all

init python:
    def reset_data():
        ## deletes all persistent data use with caution
        for attr in dir(persistent):
            if not callable(attr) and not attr.startswith("_"):
                setattr(persistent, attr, None)

        ## deletes all save games use with caution!
        for slot in renpy.list_saved_games(fast=True):
        ## a Ren'Py relaunch is nessesary
And here is a textbutton you can use.

Code: Select all

textbutton _("Delete Save Games And Persistent Data") action Confirm("Are you sure to delete all persistent data?\nThis also deletes ALL saved games and cannot be undone.\nNotice: The Game will restart!", Function(reset_data))
Happy cleaning :)