Displaying ingame variables in the save/load 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
notanumber
Newbie
Posts: 16
Joined: Mon Jul 08, 2019 6:19 pm
Contact:

Displaying ingame variables in the save/load screen

#1 Post by notanumber »

Let's say the player has to make a choice between 5 characters and that determines which route he'll take for the rest of the VN.
When he makes the branching decision i'd set a variable, for example,

Code: Select all

$chosenCharacter = 'Mary'
Is there a way to display the value of the chosenCharacter variable under each save slot in the save/load screen? Apparently there's two methods called FileSaveName(slot) and FileTime(slot) that are called in screens.rpy so maybe something like that can be used to fetch those values.
If all else fails i might just set the filesavename to the $chosenCharacter variable but it would be interesting to know anyway.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Contact:

Re: Displaying ingame variables in the save/load screen

#2 Post by hell_oh_world »

notanumber wrote: Sat Aug 31, 2019 11:37 pm Let's say the player has to make a choice between 5 characters and that determines which route he'll take for the rest of the VN.
When he makes the branching decision i'd set a variable, for example,

Code: Select all

$chosenCharacter = 'Mary'
Is there a way to display the value of the chosenCharacter variable under each save slot in the save/load screen? Apparently there's two methods called FileSaveName(slot) and FileTime(slot) that are called in screens.rpy so maybe something like that can be used to fetch those values.
If all else fails i might just set the filesavename to the $chosenCharacter variable but it would be interesting to know anyway.
You can do that through the use of store variable named "save_name"

Code: Select all


label start:
	$ save_name = renpy.input("Type the name of the Character you want to use: ").strip()
	
	## Now from this point, unless the user picked another character again, saves will be named as the name of the Character.
	## Assuming that you didn't change the file_slots screen in screens.rpy, the save_name will always be present under the save slot's thumbnail.

notanumber
Newbie
Posts: 16
Joined: Mon Jul 08, 2019 6:19 pm
Contact:

Re: Displaying ingame variables in the save/load screen

#3 Post by notanumber »

Well it kinda sucks that there's no way to fetch whatever variable/object I want, but this does get the job done, so thank you.
Also just for the record, you totally can save more than one variable into save_name separated by an underscore, and then obtain and display those two variables after parsing them in screens.rpy for every save file. Just did!

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Displaying ingame variables in the save/load screen

#4 Post by Kia »

you can use persistent data for it, https://www.renpy.org/doc/html/persistent.html

rames44
Veteran
Posts: 233
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Displaying ingame variables in the save/load screen

#5 Post by rames44 »

It is theoretically possible to do this, but would involve some Python coding. Essentially, what you’re asking for is to “peek inside” the save file. As I recall, Ren’py saves the game state using the Python “pickle” capability, so what you’d have to do is manually “unpickle” it and look at the value inside the “store” in the result.

There is a (very) brief discussion of the save file format here viewtopic.php?f=8&t=49149&p=483433&hili ... le#p483426

And some code that fiddles with savefiles here that might possibly help https://f95zone.to/threads/renpy-save-e ... ment.6456/ (this isn’t Python, but might instruct you on the file structure.)

drKlauz
Veteran
Posts: 239
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Displaying ingame variables in the save/load screen

#6 Post by drKlauz »

Simpler solution would be using save file json.
https://www.renpy.org/doc/html/config.h ... _callbacks
https://www.renpy.org/doc/html/screen_a ... l#FileJson
https://www.renpy.org/doc/html/save_loa ... .slot_json

viewtopic.php?f=8&t=56133&p=515150#p515296

Use save_json_callbacks, write variables you want to check later into json. On load screen read from json and display as needed.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

Post Reply

Who is online

Users browsing this forum: No registered users