How to Detect Consecutive button presses and what buttons were pressed

Godot Version 4.1

Ok so I made an account just for this and to be clear I do not mean buttons as in inputs I mean the button ui Ive been making an Inventory and I want to press a button then wait for another button to be pressed and be able to tell which ones were pressed the only way I can think to do this would be coding for every single combination which would be way to long

any ideas from anyone with more experience with gd script would be appreciated

Using signals is an option:

# Lets suppose you have 3 buttons named button_1, button_2 and 
# button_3, using bind() you can pass an optional parameter, here you
# can pass the node name, an id, whatever you want to use to 
# identify the button, i'll pass the reference for the button pressed
# as an example.
func _ready() -> void:
	$button_1.pressed.connect(_on_inventory_button_pressed.bind($button_1))
	$button_2.pressed.connect(_on_inventory_button_pressed.bind($button_2))
	$button_3.pressed.connect(_on_inventory_button_pressed.bind($button_3))


# p_who will be whatever you used as paramenter for the .bind()
func _on_inventory_button_pressed(p_who) -> void:
	print(p_who)

Edit: If all the inventory buttons share the same parent you can do it more easily:

func _ready() -> void:
	for button in $node_with_buttons.get_children():
		button.pressed.connect(_on_inventory_button_pressed.bind(button))


# p_who will be whatever you used as paramenter for the .bind()
func _on_inventory_button_pressed(p_who) -> void:
	print(p_who)

I’m sorry it took so long to respond can you elaborate on how your second solution works I don’t understand it

The second is the same as the first with the difference you’ll iterate the list of childs of a node (if all your buttons share the same parent) instead connect every button one by one.