I have an array:
array = ["option1", "option2", "option3"]
var selected_option
I have function assigned on an Input event:
func _input(event):
if event is InputEventKey:
if event.is_action_pressed("select_option"):
selected_option = array[randi() % array.size()]
And then I want to execute different functions based on the selected option:
func execute_option():
if selected_option =="option1": play_option1()
if selected_option == "option2": play_option2()
if selected_option == "option3": play_option3()
func play_option1(): print("Option 1 is selected")
func play_option2(): print("Option 2 is selected")
func play_option3(): print("Option 3 is selected")
So what I want to ask is that is there another less complicated way to do this. The reason I don't just print at the first function is that I want to do more with each option than just printing.