button delete persistent in menu configuration?

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
Lyedka
Newbie
Posts: 12
Joined: Thu Jan 08, 2015 1:01 am
Completed: Blackjack Deluxe
Projects: Ai Aisuru, Puri-Puri, BlGame(still unnamed), D.A.
Organization: Puzzle Deluxe
Deviantart: Liedka
Skype: Lyedka Panni
Location: this way!
Contact:

button delete persistent in menu configuration?

#1 Post by Lyedka » Thu Jan 08, 2015 1:35 am

Hello!! sorry! SORRY for my bad english D:

wanted to know if you can create a button to delete persistent data the game in the screen configuration. (delete progress and saved)

Thank you!

User avatar
shivanshs9
Regular
Posts: 54
Joined: Sun Jul 20, 2014 1:59 pm
Projects: The Destiny(http://thedestiny-cxz.blogspot.com)
Organization: Cyber-X-Zone
Location: India
Contact:

Re: button delete persistent in menu configuration?

#2 Post by shivanshs9 » Thu Jan 08, 2015 3:14 am

From http://lemmasoft.renai.us/forums/viewto ... =8&t=23068:
PyTom wrote:This is unlikely to work from within the game, as the game will re-write the file as it quits.

Your best bet would be to just set the fields that you've set back to None.
So, write for all your persistent variables in this way:

Code: Select all

persistent.variable_name = None
As for deleting saved games...

Code: Select all

for slot in renpy.list_saved_games(fast=True):
    renpy.unlink_save(slot)
# Code tested!
For explanation, check out: http://renpy.org/doc/html/save_load_rol ... -variables
Last edited by shivanshs9 on Wed Jan 21, 2015 9:15 am, edited 2 times in total.
"Destiny is a no matter of chance
It is a matter of choice
It is not a thing to be waited for
It is a thing to be achieved..."

-William Jennings Bryan
If you can dream and not make dreams your master;
If you can think and not make thoughts your aim,
If you can meet with Triumph and Disaster;
And treat those two impostors just the same,
Only then can you ever win against yourself...

nintendotoad
Regular
Posts: 42
Joined: Sat Mar 31, 2012 2:56 pm
Location: projectexist.net
Contact:

Re: button delete persistent in menu configuration?

#3 Post by nintendotoad » Fri Jan 09, 2015 1:35 pm

Code: Select all

    $ persistent._clear(progress=True)
That actually (I believe) completely resets the persistent data. 'progress' is False by default; setting it to true resets Ren'Py's progress data. This is destructive, since the dictionary keys are completely destroyed.

If you'd prefer to leave the properties but still set them to None, you can do something like this:

Code: Select all

    def destroy_persistent():
        for attr in dir(persistent):
            if not callable(attr) and not attr.startswith("_"):
                setattr(persistent, attr, None)
        return
It should be somewhat simple to make a button use one of those functions.

Code: Select all

    textbutton _("Persistent Reset") action Function(destroy_persistent)

User avatar
Lyedka
Newbie
Posts: 12
Joined: Thu Jan 08, 2015 1:01 am
Completed: Blackjack Deluxe
Projects: Ai Aisuru, Puri-Puri, BlGame(still unnamed), D.A.
Organization: Puzzle Deluxe
Deviantart: Liedka
Skype: Lyedka Panni
Location: this way!
Contact:

Re: button delete persistent in menu configuration?

#4 Post by Lyedka » Sun Jan 11, 2015 12:14 pm

shivanshs9 wrote:From http://lemmasoft.renai.us/forums/viewto ... =8&t=23068:
PyTom wrote:This is unlikely to work from within the game, as the game will re-write the file as it quits.

Your best bet would be to just set the fields that you've set back to None.
So, write for all your persistent variables in this way:

Code: Select all

persistent.variable_name = None
As for deleting saved games...

Code: Select all

for slot in renpy.list_saved_games(fast=True):
    renpy.unlink_save(slot)
# Code not tested yet
For explanation, check out: http://renpy.org/doc/html/save_load_rol ... -variables
not working the Code to remove the saved, or I do not know how to make it work D:
nintendotoad wrote:

Code: Select all

    $ persistent._clear(progress=True)
That actually (I believe) completely resets the persistent data. 'progress' is False by default; setting it to true resets Ren'Py's progress data. This is destructive, since the dictionary keys are completely destroyed.

If you'd prefer to leave the properties but still set them to None, you can do something like this:

Code: Select all

    def destroy_persistent():
        for attr in dir(persistent):
            if not callable(attr) and not attr.startswith("_"):
                setattr(persistent, attr, None)
        return
It should be somewhat simple to make a button use one of those functions.

Code: Select all

    textbutton _("Persistent Reset") action Function(destroy_persistent)
when use "textbutton _("Persistent Reset") action Function(destroy_persistent)" this message appears:
I'm sorry, but an uncaught exception occurred.

While running game code:
File "renpy/common/_layout/screen_main_menu.rpym", line 29, in script
File "game/screens.rpy", line 29, in python
NameError: name 'Function' is not defined

-- Full Traceback ------------------------------------------------------------
I'm doing wrong? as I do?

(o^u^)o Thank you! o(^u^o)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: button delete persistent in menu configuration?

#5 Post by xela » Sun Jan 11, 2015 1:37 pm

You're using old version of Ren'Py, before Function action was introduced (you need to updated Ren'Py).

On a sidenote, "Function" is bloody useless here:

Code: Select all

textbutton _("Persistent Reset") action destroy_persistent
Is what you need assuming that function does whatever it is supposed to.
Like what we're doing? Support us at:
Image

User avatar
Lyedka
Newbie
Posts: 12
Joined: Thu Jan 08, 2015 1:01 am
Completed: Blackjack Deluxe
Projects: Ai Aisuru, Puri-Puri, BlGame(still unnamed), D.A.
Organization: Puzzle Deluxe
Deviantart: Liedka
Skype: Lyedka Panni
Location: this way!
Contact:

Re: button delete persistent in menu configuration?

#6 Post by Lyedka » Sun Jan 11, 2015 4:52 pm

Thanks, I did no know that! :D But....

:( :( Ren'py doesn't want me!! ): D:

happened what I feared...
I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/screens.rpy", line 3, in execute
screen preferences:
File "game/screens.rpy", line 51, in execute

File "game/screens.rpy", line 51, in keywords

NameError: name 'destroy_persistent' is not defined

-- Full Traceback ---------------------------------------------
this is my code:
https://docs.google.com/document/d/1OHL ... Ee82xQ/pub

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: button delete persistent in menu configuration?

#7 Post by xavimat » Sun Jan 11, 2015 5:58 pm

Well, you haven't defined 'destroy_persistent' in that code...
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
Lyedka
Newbie
Posts: 12
Joined: Thu Jan 08, 2015 1:01 am
Completed: Blackjack Deluxe
Projects: Ai Aisuru, Puri-Puri, BlGame(still unnamed), D.A.
Organization: Puzzle Deluxe
Deviantart: Liedka
Skype: Lyedka Panni
Location: this way!
Contact:

Re: button delete persistent in menu configuration?

#8 Post by Lyedka » Wed Jan 14, 2015 12:57 am

Little big mistake,Image as could be defined? I'm bad at this Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1458
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love, unknown
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Contact:

Re: button delete persistent in menu configuration?

#9 Post by xavimat » Wed Jan 14, 2015 4:50 pm

Well, nintendotoad gave you the definition:
nintendotoad wrote:

Code: Select all

init python:
    def destroy_persistent():
        for attr in dir(persistent):
            if not callable(attr) and not attr.startswith("_"):
                setattr(persistent, attr, None)
        return
Put the definition outside the screen.
I don't know if this function works, but please read more carefully the answers people give you ;)
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

Post Reply

Who is online

Users browsing this forum: Ocelot