From what I can see, there's an issue with your condition:
elif Input.is_action_just_pressed("ui_up") and current_selection < 0:
You're checking if current_selection
is less than zero while you should check if current_select
is more than zero. So:
elif Input.is_action_just_pressed("ui_up") and current_selection > 0:
That'll hopefully fix the issue.
Btw an easier way to do something like this (Adding an ">" to show the selection) would be to use focus_entered
and focus_exited
signals.
You simply add the ">" when the button gains focus and remove it when it loses focus.
For example:
You could create a single script called menu_button.gd
and attach it to both of your menu nodes. The script could look something like this:
export(bool) starts_with_focus
func _ready():
connect("focus_entered", self, "_on_focus_entered")
connect("focus_exited", self, "_on_focus_exited")
if starts_with_focus:
grab_focus()
func _on_focus_entered():
text = text.insert("> ")
func _on_focus_exited():
text = text.trim_prefix("> ")
Methods: String.insert()
| String.trim_prefix()
| connect()
| grab_focus()
Remember that one of your nodes must start with focus for this to work. That's why we have an exported variable called starts_with_focus
. Using an exported variable makes it easier to choose which one of your nodes will start with focus.
Edit: Suggested a possibly easier way to do what OP wants to do.