You'll want to wire a pressed
event to each button, and then pass the button reference through the callback. From there, you can directly access the pressed button's data, including it's text
property (assuming that's what you mean by value
). Untested (and adding to your code above), but something like:
func genButtons():
for i in 3:
var button = Button.new()
buttons.append(button)
button.text = str(modText[MOD][i])
add_child(button)
button.connect("pressed", self, "_button_pressed", [button])
func _button_pressed(button):
print(button.text)