How to assign an event pressing the button from the script during the game?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By gcr
:warning: Old Version Published before Godot 3 was released.

It takes in the game from the script to assign different functions to the button click event.

:bust_in_silhouette: Reply From: ludosar

Hi,

You have to assign the event to one function, and in that function you choose to call the other functions according to a value.

var a = 1
func _pressed_button():
    if a == 1 : function_one()
    if a == 2 : function_two()

if you want to change the button’s behavior, you just have to change the value of a.