Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Ktotoetoia |
hi, im making save system for my game,i need to save instance objects variable, but this code save only last object variable:
func _save():
var save_game = File.new()
save_game.open("res://saves/save.json", File.WRITE)
var save_nodes = get_tree().get_nodes_in_group("saved")
for node in save_nodes:
if node.filename.empty():
print("persistent node '%s' is not an instanced scene, skipped" % node.name)
continue
if !node.has_method("_save"):
print("persistent node '%s' is missing a save() function, skipped" % node.name)
continue
var node_data = node.call("_save")
save_game.store_line(to_json(node_data))
save_game.close()
how can i save every object variable?