Godot Version
4.1.2
Question
In my game when player pick up item call func “add_item(item, where)”. (where it’s place where it must add inventory/hot bar/chest)
extends Node
@onready var inventory_slot_scene = preload("res://scene/UI/Inventory/Inventory Slots/inventory_slot.tscn")
var inventories = {
"inventory": [],
"hot_bar": [],
"chest": []
}
const INVENTORY_SIZE = 30
const HOT_BAR_SIZE = 10
var player_node: Node = null
var dragged_slot = null
signal inventory_updated
signal hot_bar_updated
signal chest_updated
func _ready():
inventories["inventory"].resize(INVENTORY_SIZE)
inventories["hot_bar"].resize(HOT_BAR_SIZE)
func inventory_signal_emit():
inventory_updated.emit()
print("work")
func hot_bar_signal_emit():
hot_bar_updated.emit()
func chest_signal_emit():
chest_updated.emit()
func add_item(item, where):
var updated = where + "_signal_emit"
for i in range(inventories[where].size()):
if inventories[where][i] != null and inventories[where][i]["name"] == item["name"] and inventories[where][i]["type"] == "stackable":
inventories[where][i]["quantity"] += item["quantity"]
Callable(self, updated)
return true
elif inventories[where][i] == null:
inventories[where][i] = item
Callable(self, updated)
return true
return false
When times use callable nothing happen.