The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hello. I have this Inventory System from Godot 3.x that I'm trying to convert to Godot 4.0, but I'm having some problems here and there. Most have been somewhat easy to figure out how to fix, but I'm quite stuck on this problem.

This is the file which receives the error "Parser Error: Could not resolve class "InventorySlotNode".":

class_name Hotbar_Slot_Node extends Inventory_Slot_Node

@onready var lbl_key : Label = $lbl_key

func set_slot( value ):
    super.set_slot( value )

# If you press this slot's key, activate the item if possible.
func _input( event ):
    if event.is_action_pressed( "hotbar_" + slot.key ) and slot.item and slot.item.components.has( "usable" ):
        print( "Used hotbar slot: ", slot.key )

# Set the key to be pressed to activate this slot.
func set_key():
    if lbl_key is Label:
        lbl_key.text = slot.key

This is the InventorySlotNode gdscript:

class_name Inventory_Slot_Node extends TextureRect

@onready var item_container : CenterContainer = $item_container

var slot : set = set_slot

# When the slot resource is set, draw it and connect the signals.
func set_slot( value ):
    slot = value

    if slot and slot.item:
        var item_node = ResourceManager.get_item_node( slot.item )
        item_container.add_child( item_node )

    if not is_connected("mouse_entered",Callable(InventoryManager,"_on_mouse_entered_slot")):
        connect("mouse_entered",Callable(InventoryManager,"_on_mouse_entered_slot").bind( self ))
        connect("gui_input",Callable(InventoryManager,"_on_gui_input_slot").bind( self ))

# When the slot is shown or hidden, cause a mouse exited signal so the item info hides.
func _on_item_container_visibility_changed():
    emit_signal( "mouse_exited" )

# When the item change, update the visual.
func _on_item_changed():
    for c in item_container.get_children():

    if slot.item:
        item_container.add_child( ResourceManager.get_item_node( slot.item ) )

Please feel free to throw in more questions or try to give an answer to how I might fix this problem!


Godot version Godot 4.0 RC1
in Engine by (12 points)

1 Answer

+2 votes

Copying your code and commenting out sections of InventorySlotNode that yielded unresolved symbols worked fine for me, the derived class doesn't give the parse error.

This might be a moot question, but did you try reloading the project?
Also, are there any errors in the base class? If it can't be parsed, your derived class might not be able to inherit from it.
For me, the lines where you reference ResourceManager and InventoryManager gave errors, but I guess those are globals.

by (1,957 points)

I figured the first thing I should try was reloading the project... Man, the amount of time I've spent trying to fix a problem that doesn't exist, hahahhhsh.

What did you comment out?

All the lines referencing ResourceManager and InventoryManager, these are of course not defined in my project.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.