Godot Version
v4.6.2.stable.mono.official [71f334935]
Question
im doing a save system,
func loadSave(filetoload) -> Dictionary:
var save_file = FileAccess.open(filetoload, FileAccess.READ)
var jsonDict = {}
var json = JSON.new()
while save_file.get_position() < save_file.get_length():
var json_string = save_file.get_line()
var parse_result = json.parse(json_string)
if not parse_result == OK:
print("JSON Parse Error: ", json.get_error_message(), " in ", json_string, " at line ", json.get_error_line())
continue
jsonDict["startingEntry"] = json.data
return jsonDict
func saveSave(argument) -> void:
var jsonDict = loadSave("user://saves.json")
print(jsonDict)
if !jsonDict.has("startingEntry"):
jsonDict[argument.name] = argument
else:
jsonDict.startingEntry[argument.name] = argument
var save_file = FileAccess.open("user://saves.json", FileAccess.WRITE)
var json_string = JSON.stringify(jsonDict)
save_file.store_line(json_string)
i want for all things that im saving to do in that startingEntry, i am doing Dictionary.startingEntry[newvalue] = whatiwantthevaluetobe
while that does seem to sometimes work, its not working now
the check to see if it has the startingEntry does work but the moment i try to access it an error happens
Invalid assignment of property or key argument.name with value of type âDictionaryâ on a base object of type âNilâ.
argument in this scenario is a array with 8 values including one which has name
i dont know whats the issue so im asking here, sorry if its already been answered but i looked online to no avail