How to turn StreamTexture into an String for new dictionary ?

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

So this is my code… im i writing it right? i want to put it in the empty dictionary… But when i print it out on SelectSkillGrab it return as StreamTexture… i guess it’s because the skill_icon is Load up (an Object)… how do i turn it into just a string for my dictionary ? so i can put it in the as new dictionary. because i can’t use it in LoadShortcut and SelectSkillGrab if its StreamTexture

extends CanvasLayer

onready var skillBar_path = "SkillBar/BG/HBoxContainer/"
onready var skillGrab ="UI_SkillGrab/BG/MarginContainer/VBoxContainer/HBoxContainer/VBoxContainer/HBoxContainer2/TextureRect/SkillGrab_Bar/"

onready var SelectedSkill_Texture = 

onready var assetSkill = "res://Assets/GUI/Skills/UI_Skill_Grab/"

var loaded_skills = {

var skill_grab_icon = { 

onready var skill_number = 0

func _ready() -> void:

for shortcut in get_tree().get_nodes_in_group("SkillBar_Group"):
	shortcut.connect("pressed", self, "SelectShortcut", [shortcut.get_parent().get_name()])
for button_use in get_tree().get_nodes_in_group("USE"):
	button_use.connect("pressed", self, "SelectSkillGrab", [button_use.get_parent().get_name()])

func LoadShortcuts(): #SkillBar
    for shortcut in loaded_skills.key():
	    var skill_icon = load ( assetSkill + loaded_skills [shortcut] + ".png")
	    get_node(str(skillBar_path) + shortcut + "/TextureButton").set_normal_texture (skill_icon)

func SelectShortcut(shortcut): #the choosen skill, # this is the problem
    var skill_icon = load ( assetSkill + str(loaded_skills[shortcut]) + ".png") 

    get_parent().get_node("Kinematic_Player").selected_skill = loaded_skills[shortcut]

func SelectSkillGrab(button_use): 
    if get_tree().get_nodes_in_group("USE"): #SkillGrab_Bar
	    var skill_icon = load (assetSkill + skill_grab_icon[button_use]+".png")
	    skill_number += 1
	    get_node(skillGrab + "SkillGrab" + 
	get_node(skillBar_path + "Skill_Icon" + str(skill_number) + "/TextureButton").set_normal_texture(skill_icon)
	#untuk masuk ke dictionary
	var name = "Skill_Icon" + str(skill_number)
	loaded_skills[name] =  skill_icon

	if skill_number == 5:
		skill_number = 0

when i pressed the LoadShortcut it always “Attempt to call function “set_texture” in base “null instance” on a null instance”

szccornish | 2022-06-04 14:09

:bust_in_silhouette: Reply From: Blockyheadman

As from what I can see, you would instead want to make a variable that loads in the texture so it can recognize what is is. you do that by putting someti=hing like this at the top:onready var texture = preload("res://resources/texture.png")
fit that to whatever texture you need. Hope this helps you out! :slight_smile:

as for the putting a variable into a string for a dictionary, I’d have to look into that more.

Blockyheadman | 2022-06-04 15:57