Need help with persistent data and loading save files

A place to discuss things that aren't specific to any one creator or game.
Forum rules
Ren'Py specific questions should be posted in the Ren'Py Questions and Annoucements forum, not here.
Post Reply
Message
Author
User avatar
AliceandHare_
Newbie
Posts: 10
Joined: Thu Aug 24, 2023 6:19 am
Contact:

Need help with persistent data and loading save files

#1 Post by AliceandHare_ »

Hello! I'm not that experienced with programming in Ren'py, and this is my first time trying to code professionally, so any advice is welcomed!

So far I haven't had much trouble with normal VN stuff like route branching, affection point systems, menus, etc. , but in my game we expect to release future DLC's, so I want to prepare the game for that beforehand.

I'll get to my main problem right now:

I've set up two galleries, one that unlocks images with local variables along the way on your current save file, and another one in the main menu, that unlocks the images permanently with multi persistent variables. That way, if you finish one route, you get to see all the images of Character A, but then when you start a new route for Character B, you can only see their images in their own save file, but in the main menu, you'll be able to see all of the images that you've unlocked from all the routes you've played so far. Pretty usual stuff for a VN.

My issue with this is that, ideally, I would like players to be able to load their save file in other computers if they need to for any reason, and keep playing from where they left off without any issues, but when I load a save file with the Ren'py sync system or manually copying and pasting the save file in the saves folder, the persistent data from the gallery is completely wiped, and even if in the save file you have locally unlocked 3 images already, in the main gallery, none are unlocked. The local variables are checked correctly, but the persistent ones are not (all of them stay False).

I've tried with $ renpy.retain_after_load(), $ mp.save() (for multi persistent variables), I've tried to make the game turn the persistent variables True when the local one is True as well, but nothing seems to work.

I've kept the main gallery variables as multi persistent data because when we add new chapters to the story, the code should be able to access it, but if you have better ideas, please let me know.

Any help is welcomed! Thank you very much!

User avatar
AliceandHare_
Newbie
Posts: 10
Joined: Thu Aug 24, 2023 6:19 am
Contact:

Re: Need help with persistent data and loading save files

#2 Post by AliceandHare_ »

Hi again!
I got something working that may not be super optimized, but it gets the job done!

Code: Select all

label after_load:

	#First image
	if Imagelock01 == True:
		$ mp.unlock_Imagelock01p = True
	#Second image
	if Imagelock02 == True:
		$ mp.unlock_Imagelock02p = True
This way, if I open the game as if I just installed it, and downloand my save files with the sync option, opening any of the files will advance my progress up until that point, but if I start a new run of the game, the main gallery will still display the images I've already unlocked in different runs.
AliceandHare, animator and VN dev working on dark romance otome soon to be released! <3

Post Reply

Who is online

Users browsing this forum: Amazon [Bot]