""
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 =
"GUI/SkillBar/BG/HBoxContainer/SelectedSkill/TextureRect"
onready var assetSkill = "res://Assets/GUI/Skills/UI_Skill_Grab/"
var loaded_skills = {
}
var skill_grab_icon = {
"Skill_Icon1":"Button_Skill_1",
"Skill_Icon2":"Button_Skill_2",
"Skill_Icon3":"Button_Skill_3",
"Skill_Icon4":"Button_Skill_4",
"Skill_Icon5":"Button_Skill_5",
"Skill_Icon6":"Button_Skill_6",
}
onready var skill_number = 0
func _ready() -> void:
#_on_Start_Button_pressed()
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_node(SelectedSkill_Texture).set_texture(skill_icon)
get_parent().get_node("Kinematic_Player").selected_skill = loaded_skills[shortcut]
pass
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" +
str(skill_number)).set_normal_texture(skill_icon)
#LoadShorcuts
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