Loading and Saving for Runtime-node

Godot Version

4.6

How can i save a complex level with Runtime Node

I am trying to create a saving system in for my game, but i realized there is no way to save the level, except using json file, which will be more complex for me, is any here know how can i do using the following way

SAVING CODE

func save_level(lev : int) -> void:
	var node : PackedScene = PackedScene.new();
	var save = node.pack(Main.current_level);
	
	if save == OK:
		Main.is_saved = true;
		ResourceSaver.save(node, "res://level" + str(lev) + ".tscn");
		Main.node_level[lev] = true;
	else: print("no save");

LOADING CODE

func load_level(lev : int) -> void:
	var path : String = "res://level" + str(lev) + ".tscn";
	var node = load(path);
	if node == PackedScene:
		get_tree().change_scene_to_packed(node);
	else:
		print("no folder is return");
	

yeah sure, it is creating correct file but the level file consist a MissingNode.

it would be great if any one have a simple soulution

I made a Disk Plugin for that. It has instructions on how to save/load settings, as well as nodes. Note, you are going to have to create save/load functions still, but all you do is pass all the values you want to save as a Dictionary, and then load them from the Dictionary that is returned. The system also makes it easy to persist anything. So if you wanted an RPG-style save system, where it saves the location of every dropped object, you can just have items save their own location states.

1 Like

Did you set the owner for all children nodes?

3 Likes

I’ll be careful next time, that i go with Dictionary style saving format. Thanks

1 Like

what is a owner actually?, i heard that some where in Rust lecture. I’ll search for owner on goggle now. thanks

This has nothing to do with ownership concept in Rust.

1 Like