How to save a node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Asthmar

I have an Item list node that holds my quest and I want to know how I would save the node and all the items it’s currently holding. Thanks to the Godot docs I know how to save variables like my player stats but when it comes to a node like the Item list I can’t turn it to a var to store it. So that’s my question, how to save a node like the item list using something like the save method from the godot docs. Thanks!

:bust_in_silhouette: Reply From: Avantir

You can try using the inst2dict and dict2inst methods, see here: @GDScript — Godot Engine (3.1) documentation in English

If those don’t work, your best bet is to manually serialize the properties of the nodes you know you will change, and manually deserialize them. Example:

func serialize():
	return {
		"position" : position
	}

func deserialize(dictionary):
	position = dictionary["position"]