Hi, I have been following Inventory tutorial by Arkeve. I am at the part to add mouse wheel scrolling on the hotbar.
When I added the line "and PlayerInventory.active_item_slot == slot_index" to Slot.gd the error "Could not preload" appears on the PlayerInventory.gd.
#Slot.gd
extends Panel
var slot_index
func _ready():
...
refresh_style()
func refresh_style():
# The *and PlayerInventory..* line causes error
if SlotType.HOTBAR == slot_type and PlayerInventory.active_item_slot == slot_index:
set('theme_override_styles/panel', selected_style)
elif item == null:
set('theme_override_styles/panel', empty_style)
else:
set('theme_override_styles/panel', default_style)
func pickFromSlot():
...
refresh_style()
func putIntoSlot(new_item):
...
refresh_style()
func initialized_item(item_name, item_quantity):
...
refresh_style()
#PlayerInventory.gd
extends Node
#Could not preload resource "res://inventory/Slot.gd"
const SlotClass = preload("res://inventory/Slot.gd")
var active_item_slot = 0
func active_item_scroll_up():
active_item_slot = (active_item_slot + 1) % NUM_HOTBAR_SLOTS
emit_signal("active_item_updated")
func active_item_scroll_down():
if active_item_slot == 0:
active_item_slot = NUM_HOTBAR_SLOTS -1
else:
active_item_slot -= 1
emit_signal("active_item_updated")
These 2 scripts are not attached to scene.
Slot.gd is attached to slot panel
PlayerInventory.gd is autoload.
Preload was working fine until that line is added
There is a minor difference in tutorial's and my tree set up (not sure if relevant).
Does any know why it causes this error and how to fix it? Thank you.