trying to link my players inventory from its main file to show up on a panel in my inventory hud, cant figure out what to write to make it understand single or each item in the inventory var
Inventroy panel slot 1 script
extends Node
const Explorer = preload("res://assets/characters/explorer/Explorer.gd")
var ItemClass = preload("res://assets/inventory/Item.tscn")
var Item = null
var player : Explorer = null
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func set_player(player:Explorer):
self.player = player
player.inventory_changed.connect(show_inventory)
player.inventory.connect()
func show_inventory(Item):
if global.player.inventory:
the inventroy in the
res://assets/characters/explorer/Explorer.gd script
signal inventory_changed()
var inventory = {
"empty_hands" : 1,
"gun" : 0,
"sword" : 0,
"medkit" : 0
}
and also to know which one specficly is selected at the time in the /Explorer.gd script.
var weapons_list = ["gun", "sword","medkit"]
var active_weapon = "empty_hands"
var changing_weapon = false
var weapon_change_timer = Timer.new()
func on_weapon_changed():
changing_weapon = false
maybe global.player.inventory has to be in there somwhere, or the slot node path itself
ive tried looking into it and other sources, and from what i understand i should use maybe smthing like this but not for text, i dont know how to use that to send an item tho. this is a script from a hud that dosent show th eitmens and just their values from the inventory code that i showed before
probably taking the simple approach and selecting just the
{"gun" : 0}
etc separately per inventory panel, and the other panel changing it to
“sword” : 0, and “medkit” : 0 accordingly. but I don’t know how to write the actual lines, just the concept of them.
(item:count)
if "gun" < 0,
Item = ItemClass.instantiate()
add_child(Item)
im new to godot and trying to work on a project with a friend. they only knew how to link text-based and i don’t know how to translate that into something more item like,
yet to find a solution on the internet, mostly scouting for 20 minutes a day. still no progress. any help is appreciated. i feel like I’m on the right path just not enough knowledge to actually make sense of it