"Nonexistent function [...] in base 'Resource'" on load

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Floppy

Hi everyone,

I have an inventory system that I save using ResourceSaver.save("user://inventory.tres", inventory) so that I can load it when the game starts. The problem I’m having is that it when I than load the inventory using load("user://inventory.tres") I get this error when I call a function on it:

Invalid call. Nonexistent function 'get_items' in base 'Resource'.

Now when I save the items, it’s of type Inventory but then when I load it, it’s of type Resource. Does anyone know what I can about this?

So what is Inventory here? That’s not a built-in type!

njamster | 2020-09-28 12:36

I’ve tried several different things and I am unable to reproduce this using 3.2.3. Are you able to upload a minimal reproduction project?

jonbonazza | 2020-09-29 03:10

:bust_in_silhouette: Reply From: 1MochaChan1

I’ve got the same error, it occurred because I edited the inventory.tres file in the my windows system clear the pre loaded inventory items as I couldn’t find any way to do it by code. But i made a copy of that original inventory.tres file just in case.

After I replaced my edited inventory.tres file with the previously created inventory.tres file the issue was solved you might wanna check if the file is actually created or not,

The path to the file for me was

:C:\Users\UserName\AppData\Roaming\Godot\app_userdata\Forest
Forest here is the name of my game.

The inventory.tres looks like this when opened:

[gd_resource type="Resource" load_steps=4 format=2]

[ext_resource path="res://Items/Note.tres" type="Resource" id=1]
[ext_resource path="res://Player/Inventory.gd" type="Script" id=2]
[ext_resource path="res://Items/Stick.tres" type="Resource" id=3]

[resource]
script = ExtResource( 2 )
_items = [ {
"item_reference": ExtResource( 1 ),
"quantity": 5
}, {
"item_reference": ExtResource( 3 ),
"quantity": 10
}, {
"item_reference": ExtResource( 1 ),
"quantity": 1
}, {
"item_reference": ExtResource( 1 ),
"quantity": 1
} ]

This was my reference:

I am a beginner at this, hope I helped :slight_smile: