I'm trying to create an inventory system and an object I'm getting in code is reading as Nil.
this is the related code
const slot_class = preload("res://misc/objects/item.gd")
onready var inventory_slots = $ColorRect/GridContainer
func _ready():
for slot in inventory_slots.get_children():
slot.connect("gui_input", self, "slot_gui_input", [slot])
func slot_gui_input(event: InputEvent, slot: slot_class):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT && event.pressed:
if slot.item:
holding_item = slot.instance().item
slot.pick_from_slot()
holding_item.global_position = get_global_mouse_position()