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!