Is there a way to save resources while also preserving the resources within that resource

Godot Version

Version4.2

Question

Hi everyone.
If I load other resources (which I refer to as sub resources) in one resource, will the saved resources save these loaded resources? I tried it, some worked and some didn’t.
For example, the resources in my backpack will store the items I have picked up. I use this method to save them before I find them (a save resource loads the backpack resource), and even after picking up the items, the saved file will still have them.
By the way, is it the saved file path or the resource file itself that saves sub resources as resources? Is it the
If someone could answer for me, I would greatly appreciate it original copy, a simple path, or a resource file with the same path and value?

You can find your answer in this page

1 Like

Thank you. I have watched GDScript’s video. And finally I use this below. But I’m not sure that the original resources have been deleted.
var self_load: ResInventory = load(“res://resource/res/self_load.tres”)
var task_manager: ResTaskManager = load(“res://resource/res/player_taskmanager.tres”)
var res: ResPlayer = load(“res://resource/res/res_player.tres”)
func save() → void:
res.pos = global_position
res.health = health_component.health
Global.ResSave.Player = res.duplicate()
Global.ResSave.SelfLoad = self_load.duplicate()
Global.ResSave.PlayerTaskList = task_manager.duplicate()
pass

func load() → void:
res = Global.SaveList.Player
health_component.health = res.health
global_position = res.pos
self_load = Global.SaveLoaderList.SelfLoad
task_manager = Global.SaveLoaderList.PlayerTaskList
ui_task_list.res = Global.SaveLoaderList.PlayerTaskList
ui_hotbar.update()
ui_task_list.update()
pass

1 Like