fix save system

This commit is contained in:
Nitwel 2023-12-11 09:39:34 +01:00
parent 01eabd22b3
commit f368961bf1
2 changed files with 5 additions and 5 deletions

View File

@ -5,9 +5,6 @@ extends StaticBody3D
# Called when the node enters the scene tree for the first time.
func _ready():
if HomeApi.has_connected() == false:
await HomeApi.on_connect
var stateInfo = await HomeApi.get_state(entity_id)
set_text(stateInfo)

View File

@ -85,10 +85,13 @@ func _generate_save_tree(node: Node):
func _build_save_tree(tree: Dictionary):
var new_object = load(tree["filename"]).instantiate()
get_node(tree["parent"]).add_child(new_object)
if new_object.has_method("_load"):
new_object.call("_load", VariantSerializer.parse_value(tree["data"]))
else:
for key in tree["data"].keys():
new_object.set(key, VariantSerializer.parse_value(tree["data"][key]))
get_node(tree["parent"]).add_child(new_object)
for child in tree["children"]:
_build_save_tree(child)