![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Boopy |
I can’t load a dictionary after saving it, and after searching the internet can’t seem to fix it. Looking inside the save file, it looks fine to me. Any way to make it work, am I missing a step here?
func _on_Save_pressed():
var save_file = File.new()
save_file.open("user://savefile.save", File.WRITE)
save_file.store_line(str(AutoLoad.Cash))
save_file.store_line(str(AutoLoad.Level))
save_file.store_line(str(AutoLoad.XP))
save_file.store_line(str(AutoLoad.MaxXP))
save_file.store_line(str(AutoLoad.BeatStore))
save_file.store_line(str(AutoLoad.BossesKilled))
save_file.store_line(str(AutoLoad.CurrentWeapon))
save_file.store_line(str(AutoLoad.CurrentArmor))
save_file.store_line(str(AutoLoad.CurrentHelmet))
save_file.store_line(to_json(AutoLoad.weapons))
save_file.store_line(to_json(AutoLoad.armors))
save_file.store_line(to_json(AutoLoad.helmets))
print("Saved!")
save_file.close()
func _on_Load_pressed():
var save_file = File.new()
if not save_file.file_exists("user://savefile.save"):
return
save_file.open("user://savefile.save", File.READ)
AutoLoad.Cash = int(save_file.get_line())
AutoLoad.Level = int(save_file.get_line())
AutoLoad.XP = int(save_file.get_line())
AutoLoad.MaxXP = int(save_file.get_line())
AutoLoad.BeatStore = bool(save_file.get_line())
AutoLoad.BossesKilled = int(save_file.get_line())
AutoLoad.CurrentWeapon = str(save_file.get_line())
AutoLoad.CurrentArmor = str(save_file.get_line())
AutoLoad.CurrentHelmet = str(save_file.get_line())
AutoLoad.weapons = parse_json(save_file.get_line())
AutoLoad.armors = parse_json(save_file.get_line())
AutoLoad.helmets = parse_json(save_file.get_line())
print("Loaded")
save_file.close()
Thank you for your time.