I'm looking to utilize multiple variables for my Save/Load screen's display, but I seem to have hit a snag since the only way I know how to do so is via the FileSaveName(i) function, which seems capable of facilitating only one string at a time. That is to say, any attempts to cite non "save_name" variables in the context of "File_Picker" will only show the variable's current value in the active game.
For context, my plan was to display a couple of images and a Chapter/Act description in each save file's display area with content dependent on in-game information from each save. Unfortunately, I struck this problem before I had a chance to get the concept down enough to properly put it into code, otherwise I would have posted the corresponding script for reference.
Calling variables from saved games for the Save/Load screen
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.
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.
-
- Newbie
- Posts: 1
- Joined: Sat Sep 13, 2014 12:31 pm
- IRC Nick: Binary_Chaos
- Location: Behind you
- Contact:
- BlueScorpion
- Newbie
- Posts: 14
- Joined: Thu Jul 25, 2013 4:01 am
- Contact:
Re: Calling variables from saved games for the Save/Load scr
I don't know if there's a way to read other variables from the save file, but exploiting save_name to this effect may work.
Your save_name will look something like this.
This function will break it up.
The relevant part in file_picker screen to change.
You could break it into as many parts as you wanted this way.
Your save_name will look something like this.
Code: Select all
$save_name='1|The Beginning'
Code: Select all
init python:
def get_extra_stuff(data):
if '|' in data:
chapter, title = data.split('|', 1)
else:
chapter = ''
title = data
return (chapter, title)
Code: Select all
# Format the description, and add it as text.
$ chapter, title = get_extra_stuff(FileSaveName(i))
$ description = ("% 2s. %s\n%s" % (
FileSlotName(i, columns * rows),
FileTime(i, empty=_("Empty Slot.")),
title))
text description
if chapter == '1':
## do whatever you wanted to do with the information
null width 0
elif chapter == '2':
## and etc
null width 0
- PyTom
- Ren'Py Creator
- Posts: 16093
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Calling variables from saved games for the Save/Load scr
You want to use the relatively new JSON support.
You add json to a file using a function added to config.save_json_callbacks, and retrieve it with FileJson.
As an example, you can persist the save_image variable on a per-save-slot basis, using:
And to access it from the load screen, you add:
You add json to a file using a function added to config.save_json_callbacks, and retrieve it with FileJson.
As an example, you can persist the save_image variable on a per-save-slot basis, using:
Code: Select all
init python:
def add_save_image(d):
d["save_image"] = getattr(store, "save_image", "unknown.png")
config.save_json_callbacks = add_save_image
Code: Select all
add FileJson(slot, "save_image", empty=Null(), missing="unknown.png")
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
Who is online
Users browsing this forum: Bing [Bot], Google [Bot]