Godot Version
4.7
Question
I’m trying to save the dialogue data into a resource file so it can be used by a scene later
I’ve created a resource with the class name of DialogueData in it there’s just one variable which is called data and it’s a dictionary, when saving i tried creating a new DialogueData resource then save it using ResourceSaver but nothing happens no error and the file won’t show, the code looks like this:
func _on_save_file_dialog_confirmed() -> void:
var path: String = save_file_dialog.get_current_path()
var data_to_save: Dictionary = dialogue_trees_conatiner.get_current_tab_control().save_dialogue_data()
var dialogue_res: DialogueData = DialogueData.new()
dialogue_res.data = data_to_save
ResourceSaver.save(path, dialogue_res)
Shouldn’t you be saving dialogue_res instead of data_to_save?
I just happened to be in this thread a moment ago: Issues with saving and loading resources
Make sure whatever members of your custom resource you want saved are declared as @export.
yea that’s what i’m doing i just rewrote the code back in the forums because it won’t let me paste the code for some reason
I added that but what i’m hoping to find out is how to create a new file that is that resource
Well you should post the exact code you’re actually running.
Also put some print statements in that function, to see if it’s getting called at all and to check the values of relevant variables.
Do you have a custom resource script defined with its own class_name? Then you can do my_resource = MyCustomResource.new(), set the variables as you like (again , they might need to be labeled @export if you want them to be saved by ResourceSaver, but I’m not sure. Then you can save it to whatever you want and it should create the TRES file for you.
Though, depending on your exact goals, if this is something you’re setting up while developing and not something created during gameplay, then the Godot editor Inspector panel already does a magnificent job of letting you edit and save custom resources.
Thanks you it works as intended now, what i’m trying to do is make a tool that help me create dialogue on the fly, like you said the Godot inspector is wonderful but when having nested resources it becomes a pain in the ass
I’m also planning to make it into a plugin so there people can use it as well