Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | averyknight |
I have these two functions to store and load a character’s variables:
var variable_container: CharacterVariables
func save_to_file(file: FileAccess):
# Unrelated code.
file.store_8(variable_container.inventory_size)
file.store_var(variable_container.inventory, true)
func load_from_file(file: FileAccess):
# Unrelated code.
variable_container.set_inventory_size(file.get_8())
variable_container.set_inventory(file.get_var(true))
.
One of the variables I want to store is the character’s inventory. The inventory
variable itself is an array that contains either null
or a custom resource called ItemAsset
.
.
The save_to_file()
function works regardless of what inventory
contains.
However, the load_from_file()
function works only if inventory
did not contain any ItemAsset
when it was saved; if it did, the project crashes when load_from_file()
is called.
This also happens if inventory
contained other custom resources when it was saved.
.
Debugger:
↓
Parser Error: Class "ItemAsset" hides a global script class.
The 0- :1 - at function:
is pretty weird, too.
.
Output:
↓
--- Debugging process started ---
Godot Engine v4.0.beta4.official.e6751549c - https://godotengine.org
Vulkan API 1.2.0 - Using Vulkan Device #0: AMD - AMD Radeon(TM) Graphics
editor/debugger/debug_adapter/debug_adapter_types.h:70 - Condition "path.is_empty()" is true.
--- Debugging process stopped ---
Resource file not found: res://.
.
Does anyone know how to solve this? I have tried using a newer version (v4.0.beta6.official [7f8ecffa5]), but nothing changes.