extends Control
onready var grid = $GridContainer
var inventory_slot = preload("res://dev/inventory/inventory_slot.tscn")
#POPULATE INVENTORY
func _ready():
for n in SaveAndLoad.runtime_data.building.keys():
var inventory_slot_new = inventory_slot.instance()
if SaveAndLoad.runtime_data.building[n] == false:
var item_name = SaveAndLoad.runtime_data.building[n]
var icon_texture = load(Links.house_link[n])
inventory_slot_new.set_button_icon(icon_texture)
inventory_slot_new.connect("id_pressed" , self, "_button_pressed")
grid.add_child(inventory_slot_new, true)
For each key in my dictionary -> instance scene (button) -> if key is false -> declare item name from dict -> declare texture from dict -> apply texture to button -> connect button to function (This part doesn't work) -> add button to grid container
Hey all, this is driving me crazy. I can't seem to connect my generated buttons to the buttonpressed function in my script. It has something to do with me instancing a button as a scene, since I can create buttons & connect them in a separate case.
inventory_slot_new.connect("id_pressed" , self, "_button_pressed")
I don't get an error message either. When I click one of the generated buttons in game nothing happens.