[Solved] Reading Variables in Save Files from Save Screen

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
AXYPB
Regular
Posts: 95
Joined: Thu Sep 04, 2014 3:04 am
Github: AXYPB
Contact:

[Solved] Reading Variables in Save Files from Save Screen

#1 Post by AXYPB »

I am creating a game that will have an explicit content patch that adds additional scenes. With this patch present, a variable would be written to indicate that the adult version is being used. Would it be possible to store such a value in a save file such that a save screen could read it and create an insensitive button in place of a normal hotspot to prevent loading save files that could possibly be stored at a scene not present in the unpatched version?
Last edited by AXYPB on Sun Aug 06, 2017 8:06 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Reading Variables in Save Files from Save Screen

#2 Post by philat »

I don't think players would really expect that save files would be compatible between patched and unpatched versions in the first place, so I'm not sure what the use case is here.

User avatar
carrot
Regular
Posts: 28
Joined: Fri Jul 28, 2017 7:43 am
Contact:

Re: Reading Variables in Save Files from Save Screen

#3 Post by carrot »

You can register a callback which can add data to a dictionary (which is then saved into the savegame zip, as JSON in a file named 'json') when a game is saved:

Code: Select all

def my_save_method(dict):
    pass # add data to the dictionary

config.save_json_callbacks.append(my_save_method)
And then in screens.rpy, you can use FileJson() or renpy.slot_json() to get the dictionary from a saved game, at which point you can change the behaviour to disable clicking or show an icon, etc.

AXYPB
Regular
Posts: 95
Joined: Thu Sep 04, 2014 3:04 am
Github: AXYPB
Contact:

Re: Reading Variables in Save Files from Save Screen

#4 Post by AXYPB »

Thank you. This was the solution I was seeking.

Post Reply

Who is online

Users browsing this forum: RandomHuman64