0
\$\begingroup\$

I'm trying to make UI for my game and making a button that changes its own focus neighbour when pressed:

$SettingsButton.focus_neighbour_left = $ItemGrid/Slot2

But when I press the button, it gives this error:

Invalid set index 'focus_neighbour_left' (on base: 'TextureButton') with value of type 'TextureButton'.

I tried searching around but I don't know what this error is telling me or how to fix it.

To be clear, the scene tree isn't changing and Slot2 is a TextureButton.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

Thearot figured it out, I just needed to change

$ItemGrid/Slot2

to

$ItemGrid/Slot2.get_path()

\$\endgroup\$
3
  • \$\begingroup\$ By the way Godot has NodePath literals. For example @"ItemGrid/Slot2". However, written like that it would be relative, which is not good for passing around. Because of that, I would go with $ItemGrid/Slot2.get_path() which gives you an absolute one. \$\endgroup\$
    – Theraot
    Oct 18, 2021 at 14:09
  • \$\begingroup\$ I realised the solution I found is actually incorrect and I didn't do proper testing before posting my answer, but your answer works perfectly! Thanks @Theraot! \$\endgroup\$ Oct 18, 2021 at 18:46
  • \$\begingroup\$ Reminder: you can accept your own answer. \$\endgroup\$
    – Theraot
    Oct 20, 2021 at 18:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .