Persistent datas keep clearing themselve on their own

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
WillandBran
Regular
Posts: 26
Joined: Fri Sep 08, 2017 8:18 am
Contact:

Persistent datas keep clearing themselve on their own

#1 Post by WillandBran »

Hello,

I'm having a bit of a trouble regarding my multi-persistent datas.
(As in, the ones stored in « User/Appdata/Roaming/Renpy/Name-of-the-game»)

Sometime, when I'm testing and/or troublechecking my game, my persistent datas reset on their own.
So far, I've yet to figure out what triggers it.
As far as I can tell, it's completely random whether or not it'll happen on a given day.
I'm absolutely sure this has nothing to do with me editing the script, I've had instances of the persistent datas resetting without me altering the script in any way.
And I know it has nothing to do with me exiting the game OR exiting Renpy.

I've tried many things, yet I haven't been able to link any given action to the clearance of the aformentioned datas.
And yet, they keep reseting themselves every now and then.

For the record, the code regarding the persistent datas reads:

Code: Select all

init python:
    mp = MultiPersistent("Name-of-the-game")
I'm mostly using those datas to remind the game when a chapter is over and for the in-game choices, as it's a multi-episodic games, like so:

For chapter completion, it reads :

Code: Select all

    $ mp.ch4fini = True
    $ mp.save()
And for the choices, it reads something like:

Code: Select all

    menu:
    
        "Option 1":
            $ mp.c2 = "A"
            $ mp.save()
            jump A2
        
        "Option 2":
            $ mp.c2 = "B"
            $ mp.save()
            jump A2
I really need to find a way for the persistent datas to stop clearing and reseting themselves without my say so, does anyone has any idea for how I should handle this?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Persistent datas keep clearing themselve on their own

#2 Post by Ocelot »

Are you sure that those only places where you set or change those variables?
< < insert Rick Cook quote here > >

WillandBran
Regular
Posts: 26
Joined: Fri Sep 08, 2017 8:18 am
Contact:

Re: Persistent datas keep clearing themselve on their own

#3 Post by WillandBran »

Yes... Regarding the persistent data, it's the only thing I changed.
Additionally, there's this piece of code that's meant to play when you launch the game, as a sort of DIY save system (Long story, but since the game is meant to be episodic, and span multiple "game", this is the best I've been able to produce to make that system work):

Code: Select all

    label start:
    
    
    if mp.ch1done == True:
        scene chapter
        "Do you wish to continue from last time, or do you wish to start a new savefile?"
    
        menu:
            "Continue":
                jump loading
            "Do over":
                jump newsave

    else:
        call chapter1 from _call_chapter1
    
    label newsave:
    
    "If you kickstart a new savefile, all of your progress so far will be lost, are you sure? "
    
    menu:
        
        "Yes.":
            call NV from _call_NV
        "No.":
            call start from _call_start
    
    label loading:
    
    if mp.ch20done == True:
        call chapter21 from _call_chapter21
    elif mp.ch19done == True:
        call chapter20 from _call_chapter20
    elif mp.ch18done == True:
        call chapter19 from _call_chapter19
    elif mp.ch17done == True:
        call chapter18 from _call_chapter18
    elif mp.ch16done == True:
        call chapter17 from _call_chapter17
    elif mp.ch15done == True:
        call chapter16 from _call_chapter16
    elif mp.ch14done == True:
        call chapter15 from _call_chapter15
    elif mp.ch13done == True:
        call chapter14 from _call_chapter14
    elif mp.ch12done == True:
        call chapter13 from _call_chapter13
    elif mp.ch11done == True:
        call chapter12 from _call_chapter12
    elif mp.ch10done == True:
        call chapter11 from _call_chapter11
    elif mp.ch9done == True:
        call chapter10 from _call_chapter10
    elif mp.ch8done == True:
        call chapter9 from _call_chapter9
    elif mp.ch7done == True:
        call chapter8 from _call_chapter8_1
    elif mp.ch6done == True:
        call chapter7 from _call_chapter7_1
    elif mp.ch5done == True:
        call chapter6 from _call_chapter6
    elif mp.ch4done == True:
        call chapter5 from _call_chapter5_1
    elif mp.ch3done == True:
        call chapter4 from _call_chapter4_1
    elif mp.ch2done == True:
        call chapter3 from _call_chapter3_1
    elif mp.ch1done == True:
        call chapter2 from _call_chapter2_1

    
    
    label NV:
    $ mp.ch1done = False
    $ mp.save()
    $ mp.ch2done = False
    $ mp.save()
    $ mp.ch3done = False
    $ mp.save()
    $ mp.ch4done = False
    $ mp.save()
    $ mp.ch5done = False
    $ mp.save()
    $ mp.ch6done = False
    $ mp.save()
    $ mp.ch7done = False
    $ mp.save()
    $ mp.ch8done = False
    $ mp.save()
    $ mp.ch9done = False
    $ mp.save()
    $ mp.ch10done = False
    $ mp.save()
    $ mp.ch11done = False
    $ mp.save() 
    $ mp.ch12done = False
    $ mp.save()
    $ mp.ch13done = False
    $ mp.save()
    $ mp.ch14done = False
    $ mp.save()
    $ mp.ch15done = False
    $ mp.save()
    $ mp.ch16done = False
    $ mp.save()
    $ mp.ch17done = False
    $ mp.save()
    $ mp.ch18done = False
    $ mp.save()
    $ mp.ch19done = False
    $ mp.save()
    $ mp.ch20done = False
    $ mp.save()
    scene black with dissolve
    call chapter1 from _call_chapter1_1
    return

Yes, I know that's a pretty barbaric code, but gosh darn it, what somewhat work works!

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Persistent datas keep clearing themselve on their own

#4 Post by Ocelot »

Look at your label loading. What do you think will happen when whatever is called in this humongous condition returns? Answer: game continues executing code after it. Which is label NV. So, your problem might lie here.
< < insert Rick Cook quote here > >

WillandBran
Regular
Posts: 26
Joined: Fri Sep 08, 2017 8:18 am
Contact:

Re: Persistent datas keep clearing themselve on their own

#5 Post by WillandBran »

I'm not sure what you mean by « return »? Are you talking specifically about the « return » function, or something else?

Because there's not a single instance of a return function in my whole code.

Because of the way I'm kinda twisting the code, « return » makes the whole thing go whack.
So, I instead, I use :

Code: Select all

$ MainMenu(confirm=False)()
Although I tested a return right now, it hasn't done a thing to my persistents, so, I don't think it's related.


And I'm not sure what you mean when you say that « label NV » might be the problem, if I never call NV, none of what's under it should execute? (unless I used a return, wich isn't the case) Or am I missing something?

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Persistent datas keep clearing themselve on their own

#6 Post by Ocelot »

WillandBran wrote: Thu Mar 15, 2018 3:32 pm Because there's not a single instance of a return function in my whole code.
Som you use call, which is intended to be used alongside return and don't return? I am not usre in what mess it leaves game state and if it will result in problems, but why exactly do you use it at all instead of jump?

Anyway, it seems that Multipersistent data is currently bugged (try to update RenPy, it might be already fixed), and randomly wipes data.
viewtopic.php?f=8&t=48399

Is there any reason to use MultiPersistent instead of simple Persistent data? Nothing in code you posted justifies its use: all data it uses is set in the same game.
< < insert Rick Cook quote here > >

WillandBran
Regular
Posts: 26
Joined: Fri Sep 08, 2017 8:18 am
Contact:

Re: Persistent datas keep clearing themselve on their own

#7 Post by WillandBran »

Oh, so the multi-persistent do have a problem on read... Hon...
Well I guess we might have a culprit then... I suppose?
I'm using « call » because I'd rather have multiple, small script file than a singular big one.
It was just more convenient to organize things this way.

Additionally, regarding the start label I pasted here.
In the long term, I'm hoping to find a more organic and less convoluted way of doing things, but as of now, that's the only solution I found to make things work the way I want them to.


The bottom line is that I'm planning on releasing short chapters once every month, and I'm having a really hard figuring a way to make that work while also being ergonomic for the reader.
Ideally, I'd like the player to be able to hop directly into the new chapter provided he played the previous ones.
As of now, my plan was to make the player download the full, updated game each and every team a new chapters come out. (Wich is really not ideal, but I haven't found another way. Too many chapters that are too short to stand on their own)

Hence why making the persistents work is mandatory for me.
Though I've read about people who managed to crank up some matter of DLCs for Ren'py-made games, so I will probably look into that.

At some point.

For now, I'm mostly focusing on the game in and off itself.

I'll probably come back to the forum after I've meddled with the project a bit on my own.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Persistent datas keep clearing themselve on their own

#8 Post by Ocelot »

I'm using « call » because I'd rather have multiple, small script file than a singular big one.
I fail to comprehend this reasonong. The only difference of call from jump, is that call marks place for subsequent return. That is all. All other differences are meant to work with returning too.
Hence why making the persistents work is mandatory for me.
But why MultiPersistent? Why not a normal, tested by many and working for everyone Persistent data? What in the game what requires this extremely rarely used MultiPersistent? DDLC uses persistent data, not MultiPersistent.
< < insert Rick Cook quote here > >

WillandBran
Regular
Posts: 26
Joined: Fri Sep 08, 2017 8:18 am
Contact:

Re: Persistent datas keep clearing themselve on their own

#9 Post by WillandBran »

Hon, I didn't get the difference between a jump and a call it seems.
Thanks a bunch for the info.

And yeah, if I build my game around DLCs, I probably won't have a use for multipersistents.
But I began coding before learning about the Dlcs.

User avatar
Ocelot
Lemma-Class Veteran
Posts: 2401
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: Persistent datas keep clearing themselve on their own

#10 Post by Ocelot »

my plan was to make the player download the full, updated game each and every team a new chapters come out
I do not see why you would use a multipersistent here. It is just a simple common game update which does not require anything out of ordinary. MultiPersistent is for something like "I have several different games, which do not share anything, have different launchers and probably are going to be installed simultaneously at some point; and I need for them to intract with each other"
< < insert Rick Cook quote here > >

Post Reply

Who is online

Users browsing this forum: No registered users