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 )
set_key()
# 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 )
slot.item.components.usable.use()
# 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("mouse_exited",Callable(InventoryManager,"_on_mouse_exited_slot"))
connect("gui_input",Callable(InventoryManager,"_on_gui_input_slot").bind( self ))
slot.connect("item_changed",Callable(self,"_on_item_changed"))
# 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():
c.queue_free()
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!
Cheers!