I am having these error for my inventory system in gamemanager script
try user://inventory.tres
with two /
s
E 0:00:01.252 load_interactive: Cannot open file 'user://inventory.tres'.
<C++ Error> Condition "err != OK" is true. Returned: Ref<ResourceInteractiveLoader>()
<C++ Source> scene/resources/resource_format_text.cpp:1183 @ load_interactive()
<Stack Trace> GameManager.gd:17 @ initialise_player()
GameManager.gd:8 @ _process()
Is the file actually there? Click Editor -> Open Editor Data/Settings Folder.
Then go to app_userdata/NAME_OF_YOUR_GAME/ and make sure inventory.tres is there and named correctly.
`extends Node
signal player_initialised
var player
func process(delta):
if not player:
initialise_player()
return
func initialise_player():
player = get_tree().get_root().get_node("Spatial/player")
if not player:
Handle case where the player is not found
return
emit_signal("player_initialised", player)
connect_player_inventory_signal()
initialise_player_inventory()
func connect_player_inventory_signal():
if player and player.inventory:
player.inventory.connect("inventory_changed", self, "_on_player_inventory_changed")
func initialise_player_inventory():
if player and player.inventory:
var existing_inventory = load("user://inventory.tres")
if existing_inventory:
player.inventory.set_items(existing_inventory.get_items())
player.inventory.add_item("coke", 5)
else:
player.inventory.add_item("pizza", 4)
func _on_player_inventory_changed(inventory):
Handle inventory changes and saving
if inventory:
ResourceSaver.save("user://inventory.tres", inventory)
else:
Handle case where inventory is not available or empty
pass
`
i think this code supposed to make an inventory.tes file
User data persists. The file should be there if that code actually made it. You should be able to copy it back into the godot project and verify that it saved correctly.