Godot Version
4.6.3
how should i interact with my inventory and also please if there is some recomendation on game structure, give it to me because im lost!
i started creating survival game and made inventory system from tutorial, but made it fit my needs. It contains inventory script with functions like (add_item, remove_item… so on). I created “gameManager” that contains the logic of collecting items, and from there i tried to call the “add_item” function that takes in "ItemData” but it doesnt work. error that it shows tells me that it cant recognice or find the “Inventory (node) that contains the script and that i call like this “@onready var inventory: Inventory = $“../Player/Inventory””
extends Node
@onready var inventory: Inventory = $"../Player/Inventory"
@export var WOOD: ItemData
var wood_scene = preload("res://Items/collectables/scenes/wood.tscn")
var item_dict : Dictionary = {0: WOOD}
func _ready() -> void:
var wood_instance = wood_scene.instantiate()
add_child(wood_instance)
func _add_to_inv(item : int):
var success = inventory.add_item(item_dict[item])
print(success)
func add_item (item: ItemData) -> bool: #this is from Inventory script
var slot : ItemSlot = get_item_slot(item)
if slot and slot.quantity < item.max_stack:
slot.quantity += 1...
and error happens when i call the “_add_to_inv” function
