I want to connect the pressed signal of 9 buttons by code but since the .connect method doesn’t use a string argument (which I could easily modify in my loop) I don’t know how to connect each of them.
I want to do something like this:
for i in buttonArray:
get_node("button%d" %i).pressed.connect("on_pressed_button_%d" %i)
Expecting it will connect the 9 pressed signals to my 9 on_pressed_button function
I found a post for an older Godot version that use only one "on_pressed" function for the whole list and get the button in the parameter.
for button in get_tree().get_nodes_in_group("my_buttons"):
button.connect("pressed", self, "_some_button_pressed", [button])
func _some_button_pressed(button):
print(button.name)
Is something like this still possible in the actual 4.1 version ?