0 votes

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.

in Engine by (12 points)
edited by

You can click on on the error messages and usually see a stack_trace. Can you get more information out of it with that, also you can copy the error message, with right click and post that. Makes it easier to use google.

Maybe you haven't changed the scene between saving and loading and that may be a problem?

Ahh okay, I updated the post with all of the error messages.

What exactly do you mean by changing the scene? Switch to a different scene or like change a node or something in the current scene?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.

Categories