Page 1 of 1

[SOLVED] Gallery - Persistent data not saved

Posted: Sat Jun 26, 2021 8:58 pm
by Bren
Hi guys,

Update: I had included the function "persistent._clear(progress=True)" somewhere else in my script long time ago and I completely forgot about it, so obviously all persistent data would be cleared every time I restart the game. I removed it and it works just fine!

*************

I have been stuck for a while on what is probably a simple issue, but I really can't figure out what exactly!

I have used Ren'py documentation to build a very simple gallery with locked CGs - they get unlocked as the story goes through persistent variables. It works just fine as I keep playing, but for some reason, I cannot get to make these persistent data saved once I restart / reload the game!

Gallery code is the following:

Code: Select all

init python:

    g = Gallery()

    g.locked_button = "gallery_locked_button.png"
    
    g.button("slot01")
    g.condition("persistent.cg1_unlocked")
    g.image("cg1.png")

    g.button("slot02")
    g.condition("persistent.cg2_unlocked")
    g.image("cg2.png")

    g.transition = dissolve


screen gallery:

    tag menu

    grid 2 2:

        xfill True
        yfill True

        add g.make_button("slot01", "CG/CG6_raph_vs_seb.png", xalign=0.5, yalign=0.5)
        add g.make_button("slot02", "CG/CG5_raph_alice_tower.png", xalign=0.5, yalign=0.5)

        textbutton "Return" action Return() xalign 0.5 yalign 0.5
        textbutton "Main menu" action MainMenu() xalign 0.5 yalign 0.5

And inside the script.rpy I put the following:

Code: Select all

a 'You will unlock new CGs!'

$ persistent.cg1_unlocked = True
$ persistent.cg2_unlocked = True
$ renpy.save_persistent()

Once I restart the game, it seems that both persistent data go back to Null as the CGs get locked again. Would anyone have an idea on how I can make sure the persistent data are saved?

Many thanks!

Re: Gallery - Persistent data not saved

Posted: Sun Jun 27, 2021 3:55 am
by Ocelot
Is this all code? Does anything, anywhere else reference cg1_unlocked ?

Re: Gallery - Persistent data not saved

Posted: Sun Jun 27, 2021 9:07 am
by Bren
Hi Ocelot, thanks for your help!

Yes I'm afraid so - I've even tried changing the names only in these specific parts to make sure there would be not impact from any other forgotten reference, but no luck either.

Do I need to declare these persistent data first somewhere? Or add a special authorization somewhere in Renpy's code to be allowed to register my own persistent data?

Re: Gallery - Persistent data not saved

Posted: Sun Jun 27, 2021 10:16 am
by Bren
Quick update: it seems that actually no persistent data can be saved on this specific project - I tried it over by creating a whole new project and it worked just fine.

The project I'm working on has been c/c directly from another project's folder in the renpy-7.3.5-sdk folder - I have then updated the options.rpy file to change the name of the project and modify the config.save_directory variable accordingly. Could the issue come from this? Is there another step I need to do?
FYI the new save_directory has been properly created and I can see in the relating folder (%APPDATA\RenPy\<config.save_directory>) all saved files and persistent file necessary for the game to launch.

Re: Gallery - Persistent data not saved

Posted: Sun Jun 27, 2021 10:17 am
by rayminator
I have read that you used the one from the renpy documents Image Gallery
but it looks like that you are missing something... something like this...

Code: Select all

 # The final two buttons contain images that show multiple pictures
    # at the same time. This can be used to compose character art onto
    # a background.
    g.button("dawn mary")
    g.unlock_image("dawn1", "mary dawn wistful")
    g.unlock_image("dawn1", "mary dawn smiling")
    g.unlock_image("dawn1", "mary dawn vhappy")

    g.button("dark mary")
    g.unlock_image("beach2", "mary dark wistful")
    g.unlock_image("beach2", "mary dark smiling")
    g.unlock_image("beach2", "mary dark vhappy")

Re: Gallery - Persistent data not saved

Posted: Sun Jun 27, 2021 10:44 am
by Bren
Found the issue! It was such a rookie mistake from me, I'm super ashamed => long time ago I had created a stupid file including persistent._clear(progress=True). I thought this was called only when I activated a specific function, but turns out it was actually active every single time I would restart the game. Just removed this persistent._clear(progress=True) and it works perfectly fine!

Very sorry for the stupid question (issue was actually unrelated to the code displayed in this topic), and many thanks for all your help!