Before I start, I just wanted to say that I’m still a pretty big noob when it comes to Godot and coding in general.
I want to be able to save some text inside a label and load that same text again. I found this thread which seemed handy as it did not involve as much code as other saving methods.
So I tried to use the code that makes a my_scene.tscn file so I can save the text in my label, the problem is that if I want to load this code so we can continue with our "game" it gives some error messages.
we used this code for the saving:
extends TextureButton
onready var Paneel = get_node("Panel")
func _onready():
var packed_scene = Paneel
func _on_TextureButton4_pressed():
var packed_scene = PackedScene.new()
packed_scene.pack(get_tree().get_current_scene())
ResourceSaver.save("res://my_scene.tscn", packed_scene)
And this code for loading:
Extends TextureButton
onready var Paneel = get_node("Panel")
func _onready():
var packed_scene = Paneel
func _on_TextureButton5_pressed():
var packed_scene = load("res://my_scene.tscn")
var my_scene = packed_scene.instance()
add_child(my_scene)
When I press my save button I do not get any error messages but when I press the load button, it gives us the following error messages (again, I’m a noob).
0:00:18:0877 - res://my_scene.tscn:7659 - Parse Error:
----------
Type:Error
Description:
Time: 0:00:18:0877
C Error: res://my_scene.tscn:7659 - Parse Error:
C Source: scene\resources\scene_format_text.cpp:277
C Function: ResourceInteractiveLoaderText::_parse_node_tag
0:00:18:0880 - Condition ' err != OK ' is true. returned: RES()
----------
Type:Error
Description:
Time: 0:00:18:0880
C Error: Condition ' err != OK ' is true. returned: RES()
C Source: core\io\resource_loader.cpp:149
C Function: ResourceFormatLoader::load
0:00:18:0884 - Failed loading resource: res://my_scene.tscn
----------
Type:Error
Description: Failed loading resource: res://my_scene.tscn
Time: 0:00:18:0884
C Error: Method/Function Failed, returning: RES()
C Source: core\io\resource_loader.cpp:186
C Function: ResourceLoader::_load
I do not know for sure what any of these mean, any help or referral to a better solution of saving a simple line of text would be much appreciated.