So i'm currently trying to learn how to make games using godot. Right now i'm trying to create my own inventory system for my game. I have a function that adds an item to the inventory.
I want to add an item to the inventory every time player collides with a certain object (for example, if the player collides with a carrot, i want this carrot to be added to his inventory).
Here is my script for the item:
extends Node2D
export var my_res: Resource
onready var slots_script = get_node("/root/Slots")
func _on_Area2D_area_entered(area):
slots_script.AddItemToInventory(my_res)
And here is the function that this item is triggering:
func AddItemToInventory(item):
print("adding")
for i in range(0, slots.size()):
if slots[i].isFull == false:
slots[i].isFull = true
slots[i].addItem(item)
break
For some reason the only part of this function that is triggering right now is the first line that is printing a message in the console.
I tested this function before so there should be no problem with it. I think there is something wrong with my item script but i can't figure out what. I would really like to get some help with it
P.S I'm just a beginner so please don't judge my coding skills too much