Godot Version
4.0 stable
Question
Hi! I’m new. I am creating a fighting game right now, and I made some decisions that led me to a huge if elif statements block. I decided to use match instead. The problem I ran into: I can’t understand if there’s a way to assign a single value from enum list of values based on the event.action list. I have inputCheck variable that gets an input and puts it in the inputReg array, I have enum INPUTNAME with, well, input names. I need to assign a single value from this enum to inputCheck in as few lines as possible according to event.is_action_pressed without huge elif statements. Basically:
func _unhandled_input(event):
if event.is_action_pressed("button A", ..., "Button Y"): inputCheck = INPUTNAME.key()[INPUTNAME.A, ... INPUTNAME.Y]
I would appreciate any alternatives you can provide, but the priority is to resolve given problem in gdscript, as I may need something similar in the future, please!