Im trying to use the tutorial from the Doc’s on how to save nodes. I duplicated each step and im sure it should work- but it get’s stuck at : “code” : . It does not seem to matter what node i want to check, none has a node.scene_file_path()!? I tried to print(…), but i get an empty line between notificaions that get printed whenever a nodes scene_file_path() is empty.
i have no clue what’s wrong. PS: the little arrow is added afterwards.
var file = FileAccess.open(save_path, FileAccess.WRITE)
file.store_var(Year)
var save_planets = get_tree().get_nodes_in_group("Saving")
for node in save_planets:
-> if node.scene_file_path.is_empty():
print("persistent node '%s' is not an instanced scene, skipped" % node.name)
continue
Your nodes Core and Earth are not scenes, did you make them local? as I see you have a “Earth” scene in the tabs but it’s root appears to be a Node3D not a MeshInstance3D.
What data are you trying to save? This saving code relies on the scene path likely to re-instantiate scenes that were dynamically instantiated, like if your “Earth” node shouldn’t be in the scene until a certain point or purchase.
The data im trying to save are variables. But the script they use is shared/reused by like 40 other nodes differently named. So i want to save each node via name, access and save theyr save() func and of course reload them.
Are your nodes to be dynamically instantiated? I.E. will “Earth” always be there, under “Galaxy”? If so, maybe you should save the node path from .get_path(), you can remove the if node.scene_file_path.is_empty(): block.
All nodes are always under “Galaxy” just the variables that “Earth” and “Core” share are independently changed, thats why i can’t just use store_var(node.variable) that way every node sharing this var would have the saved value. I see i was on a whole different trip, i need a new idea.
The node_path thing seems to be a good approach though!