I have this code checking if the date is the same (going to use it to add to a stored variable and unlock things one at a time) but when I tried to add a second variable to the dictionary "test" in this case I get an error "Invalid get index 'test' (on base: 'Dictionary')" I am not sure how to fix this. Any help would be appreciated.
extends Node2D
var save = {"day": 0, "test": 0}
# do not try to save in _ready, it doesn't work
func _ready():
var test = OS.get_date().day
load_data()
if test == save.day:
print("Same Day")
if save.test == 0:
print("equals 0")
else:
save.day = test
save_data()
print("New Day")
#
## saves everyhing in the "save" variable
func save_data():
var file = File.new()
file.open("user://save_date",file.WRITE_READ)
file.store_var(save)
file.close()
#
## and load
func load_data():
var file = File.new()
if not file.file_exists("user://save_date"):
return false
file.open("user://save_date",file.READ)
save = file.get_var()
file.close()
return true