Hi!
A quick question here. I am trying to come up with a save/load system for my game. Everything works fine so long as I work with boolean variables. However, I get errors if I save a string variable and try to load.
This is my code:
var save_path = “user://save_game.save”
func save():
var file = FileAccess.open(GlobalVars.save_path, FileAccess.WRITE)
file.store_var(GlobalVars.button_date1_text) #this is a string
file.store_var(GlobalVars.button_date2_text) #this is a string
file.store_var(GlobalVars.button_date3_text) #this is a string
file.close()
func load():
if FileAccess.file_exists(GlobalVars.save_path):
var file = FileAccess.open(GlobalVars.save_path, FileAccess.READ)
GlobalVars.button_date1_text = file.get_var(GlobalVars.button_date1_text)
GlobalVars.button_date2_text = file.get_var(GlobalVars.button_date2_text)
GlobalVars.button_date3_text = file.get_var(GlobalVars.button_date3_text)
And this is the error I get:
Invalid type in function ‘get_var’ in base ‘FileAccess’. Cannot convert argument 1 from String to bool.
(my indents look ok on my screen but for some reason the message does not display them properly)
Thanks!