#How do I set the focus neighbor of a button through script?

1 messages · Page 1 of 1 (latest)

violet mulch
#
            if file == Global.file1:
                $"SaveSelection/Slot_One/Save_Found".visible = true

                $"SaveSelection/Slot_One/Load_Save".set_text("Continue") 
                $"SaveSelection/Slot_One/Load_Save".focus_neighbour_right = "SaveSelection/Slot_One/Save_Found/Delete_Save" # This is the error

                $"SaveSelection/Slot_One/Save_Found/Area_Name".text = node_data["level"].trim_prefix("res://Scenes/Game/Levels/Rooms/").trim_suffix(".tscn").replace("_", " ")
                $"SaveSelection/Slot_One/Save_Found/Playtime".text = str(time_convert(node_data["playtime"]))

I have to set the focus neighbor of this button dynamically but I can't figure out how to do it script wise without an error popping up along the lines of
Invalid set index focus_neighbour_right (on base: Button) with value of type String
I've tried other ways of getting the node path wit no luck what do I do lol

#

Fixed it I was using the British spelling of the word

#

Godot should make it so that the value copied isn't different lol

maiden aspen
#

for the sake of readability I suggest you create variables to store your node references. So you don't have to write their paths in every line.