I'm working on my Inventory UI. So far, I can populate an ItemList with various items and get it to display these item names as desired. Where I'm tripping up is the item quantity. Here is the section in question:
func PopulatePanel():
var counter = loot_dic.size()
while counter != 0:
var icon = load("res://Scenes/Menus/Inventory/Icons/" + InventoryImport.loot_data[location]["Item" + str(counter) + "Name"] + ".svg")
var name = InventoryImport.loot_data[location]["Item" + str(counter) + "Name"]
loot_list.add_item(name, icon, true)
item_index = loot_list.get_index() ### This seems to be where it's getting hung up ###
quantity = loot_dic[counter][1]
loot_list.set_item_tooltip(item_index, str(quantity))
counter = counter - 1
print(quantity)
func _on_LootList_item_selected(index):
var name = loot_list.get_item_text(index)
var item_quantity = loot_list.get_item_tooltip(item_index)
loot_name.set_bbcode("[center]" + name + " - " + str(item_quantity) + "[/center]")
What I think is supposed to happen is that for each item generated, the quantity will be stored in that item's tooltip. Set the tooltip, get the tooltip, all is well.
Quantities will print in the Output, but when implemented, only the first item will have a quantity, and it's usually wrong unless it's the only item. Sometimes I will tweak it and it ends up displaying the same quantity for all of them. I figured the tooltip was a safe, already-included option to use versus creating a new label and yadda yadda. What am I missing?