set_text Label issue

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eclectia

Hi! I’m following this tutorial on inventory/item stuff and so far I’ve had no problems with it.

I have, though, had a problem when trying to define the label text.
For whatever reason, the label won’t add the text I’ve loaded to the dictionary to the scene when I load it up. It just comes back blank.

This is my code, all of it, just in case there is an error I’ve not noticed:

extends Control

var map_name
var loot_count
var loot_dic = {}

func _ready():
map_name = “Sewers01”

func DetermineLootCount():
var ItemCountMin = ImportData.loot_data[map_name].ItemCountMin
var ItemCountMax = ImportData.loot_data[map_name].ItemCountMax
loot_count = randi() % ((int(ItemCountMax) - int(ItemCountMin)) + 1) + int(ItemCountMin)
print (loot_count, “Determine Loot Count Success”)

func LootSelector():
for i in range(1, loot_count + 1):
var loot_selector = randi() % 100 + 1
var counter = 1
while loot_selector >= 0:
if loot_selector <= ImportData.loot_data[map_name][“Item” + str(counter) + “Chance”]:
var loot =
loot.append(ImportData.loot_data[map_name][“Item” + str(counter) + “Name”])
loot.append((int(rand_range(float(ImportData.loot_data[map_name][“Item” + str(counter) + “Min”]), float(ImportData.loot_data[map_name][“Item” + str(counter) + “Max”])))))
loot_dic[loot_dic.size() + 1] = loot
loot_selector = loot_selector - ImportData.loot_data[map_name][“Item” + str(counter) + “Chance”]
counter = counter + 1
print(loot_dic, “Loot Dic Success”)

func PopulatePanel():
var counter = loot_dic.size()
print (counter)
for i in get_tree().get_nodes_in_group(“TextureRect/ScrollContainer/VBoxContainer/Loot1”):
if counter != 0:
get_node(str(i.getpath()) + “/Label”).settext(loot_dic[counter][0])
counter = counter - 1

:bust_in_silhouette: Reply From: scrubswithnosleeves

In the future, try not to post such a lengthy code snippet and use the code block formatting. Most people probably won’t respond because they don’t want to read it.

IDK if this is just an error made in posting but you have .settext(loot_dic[counter][0]) instead of .set_text(). I am surprised Godot didn’t throw an error and let you know where that was.