[SOLVED] Crashes after resetting game - Persistent data/ Achievements

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
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

[SOLVED] Crashes after resetting game - Persistent data/ Achievements

#1 Post by Kinmoku »

Hi all. I had issues a while back with an achievement ("true detective") where it's achieved when every item in the game has been clicked on. It cannot be done in one playthrough, so the data is persistent. My original post is here: viewtopic.php?f=8&t=45439&p=463461#p463461

This worked fine until the game is reset. If it's reset, and you click on an item, the game crashes. Sadly, I have only just discovered this terrible bug but I want to fix it.

Here's my code in script.rpy:

Code: Select all

init -2:
    default persistent.itemcount = set()
Achievement registers after an exploration scene (this causes crashes too):

Code: Select all

    if len(persistent.itemcount) == 31:
        $achievement.grant("detective")
        init:
            $achievement.register("detective")
My reset button jumps to:

Code: Select all

label resetprogress:
     $ persistent._clear(progress=True)
     $ persistent.endings = []
     call screen main_menu
I assume that I need "persistent.itemcount = 0" or something, but whatever I try seems to cause more crashes. Any ideas?
Last edited by Kinmoku on Thu Jun 21, 2018 4:38 am, edited 1 time in total.

User avatar
gas
Miko-Class Veteran
Posts: 842
Joined: Mon Jan 26, 2009 7:21 pm
Contact:

Re: Crashes after resetting game - Persistent data/ Achievements

#2 Post by gas »

I dunno why you did an init before assignin the achievement.register...or anything else. Achievement. is a function that play ar regular runtime.
If you want to debate on a reply I gave to your posts, please QUOTE ME or i'll not be notified about. << now red so probably you'll see it.

10 ? "RENPY"
20 GOTO 10

RUN

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Crashes after resetting game - Persistent data/ Achievements

#3 Post by Kinmoku »

gas wrote: Tue Jun 19, 2018 5:31 am I dunno why you did an init before assignin the achievement.register...or anything else. Achievement. is a function that play ar regular runtime.
'cause I didn't know any better, haha! Anyway, I changed it and it still doesn't work. In fact, it resets the game every time I load.

An error is still being thrown up when I manually reset the game and click on an item too :(

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: Crashes after resetting game - Persistent data/ Achievements

#4 Post by kivik »

What's the error?

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Crashes after resetting game - Persistent data/ Achievements

#5 Post by Kinmoku »

kivik wrote: Wed Jun 20, 2018 5:04 am What's the error?
Sorry, it's the same one I had originally, but this time it comes back after reset only. download/file.php?id=44763&mode=view

When I remove the "init -2:" the error is 'RevertableList' object has no attribute 'add'. I attached the full report.
Attachments
Screen Shot 2018-06-20 at 11.46.07.png

User avatar
Kinmoku
Miko-Class Veteran
Posts: 591
Joined: Mon Aug 11, 2014 9:39 am
Completed: One Night Stand
Projects: VIDEOVERSE
Tumblr: gamesbykinmoku
itch: kinmoku
Location: Germany
Contact:

Re: Crashes after resetting game - Persistent data/ Achievements

#6 Post by Kinmoku »

Okay, I've figured it out! In case anyone is interested, here are the changes I made:

Code: Select all

    default persistent.itemcount = set()
- removed the init

Code: Select all

label resetprogress:
     $ persistent._clear(progress=True)
     $ persistent.endings = []
     $ persistent.itemcount = set()
     call screen main_menu
- reset progress adds $ persistent.itemcount = set()

I've tested it a few times and it seems to have worked and reset properly :) Fingers crossed nothing else is lurking haha.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: [SOLVED] Crashes after resetting game - Persistent data/ Achievements

#7 Post by kivik »

Hey sorry I started a reply yesterday but got interrupted and lost the post!

I was gonna say you probably want to remove your default persistent.itemcount = set() statement:

If anyone starts a new game, that line gets run - which wipes the itemcount variable. You'll probably want to create a label or function and call it at the beginning of a new game:

Code: Select all

label init_progress:
    if not persistent.itemcount:
        persistent.itemcount = set()

label start:
    call init_progress
I haven't tested it and I'm still a bit unfamiliar with python, but you want to check whether the itemcount exists or not first, and create it if not. Then it stays persistent across different games but doesn't crash on first run of the game.

You may want to mix the resetprogress label into it, by calling resetprogress if persistent.itemcount hasn't been set instead though.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Starberries