My problem is the following, I have a dictionary to save some characteristics of the characters, everything works fine, except that when I change some value of the dictionary within the game, I save the game progress after modifying the value, I close the game, I open it , I load the progress, the dictionary value returns to its default value, it does not save the change that had been made previously, is that understood? Here I leave the code if someone can help me, it would be excellent, or guide me in the right direction on how to save the progress and changes made.
char_vars.rpy
Code: Select all
init python:
# Defines the information for each character's images and story path
characters = {
#Sophie
"sophie": {
"locked_image": "sophie_locked.png",
"idle_image" : "sophie_idle.png",
"hover_image" : "sophie_hover.png",
"story_label" : "sophie_story",
"tooltip" : "Sophie",
"tooltip_lock": "This player is locked",
"unlocked" : True
},
#Mia
"mia": {
"locked_image": "mia_locked.png",
"idle_image" : "mia_idle.png",
"hover_image" : "mia_hover.png",
"story_label" : "mia_story",
"tooltip" : "Mia",
"tooltip_lock": "This player is locked",
"unlocked" : False
},
}
character_selection.rpy [To show characters availables and unlocked.]
Code: Select all
# Screen to switch between character stories.
screen character_selection():
add "background.png"
frame:
background None
align (0.0, 0.0)
xminimum (1920)
yminimum (1080)
# Left navigation arrow
frame:
background None
align (0.05, 0.5)
if character_index > 0:
imagebutton at Transform(zoom=0.5):
auto "images/arrow_left_%s.png"
action SetVariable("character_index", character_index - 1)
# Character image
$ char_id, char_info = list(characters.items())[character_index]
$ image_to_display = char_info["idle_image"] if char_info["unlocked"] else char_info["locked_image"]
$ hover_image = char_info["hover_image"] if char_info["unlocked"] else image_to_display
$ tt = char_info["tooltip"] if char_info["unlocked"] else char_info["tooltip_lock"]
$ action = Jump(char_info["story_label"]) if char_info["unlocked"] else NullAction()
# Frame for Character image
frame:
background None
align (0.5, 1.0)
imagebutton at test_transform:
idle "images/" + image_to_display
hover "images/" + hover_image
tooltip tt
action action
xalign 0.3
yalign 1.0
# Right navigation arrow.
frame:
background None
align (0.95, 0.5)
if character_index < len(characters) - 1:
imagebutton at Transform(zoom=0.5):
auto "images/arrow_right_%s.png"
action SetVariable("character_index", character_index + 1)
# ImageButton for quit the game.
frame:
background None
xalign 1.0
yalign 0.0
imagebutton:
auto "images/quit_%s.png"
action MainMenu()
# Tooltip Message
$ tooltip = GetTooltip()
if tooltip:
nearrect:
focus "tooltip"
prefer_top True
frame:
style "frame_style"
text tt
# character_selection styles and transforms
style frame_style:
background "#0000009a"
padding (20, 25, 20, 15)
xalign 0.5
transform test_transform:
on idle:
easein 0.5 zoom 1.0
on hover:
easein 0.5 zoom 1.05
Code: Select all
default persistent.dialogueBoxOpacity = 1.0
image white = Solid("#fff")
# Label for start the game and show the screen with characters selection and their story.
label start:
scene white
"Test"
call screen character_selection
return
# Labels for character stories.
label sophie_story:
$ characters["mia"]["unlocked"] = True # unlock Mia
"Unlock Mia's Story..."
jump start
label mia_story:
"Test the game"
jump start