How do you make input/keyboard combinations?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By joeyq

I want to do fighter style game and want to know how to make a key combos result in an animation or attack a la Street Fighter, Tekken, Mortal Kombat etc.
For example, how do you do:
-Street Fighter Ruy’s fireball (Down, Down + Forward, Forward, Punch)?
-Street Fighter Guile’s sonic boom (press Back for 2 seconds, then Forward, Punch)
-Mortal Kombat Liu Kang’s Flying Dragon Kick (Forward, Forward, Kick)
I think with these three different examples explained you could make any keyboard combo.
Thanks in advance!

:bust_in_silhouette: Reply From: gravit22

Hello. solved this problem for myself recently. I won’t explain you everything because I did a lot of staff in order to implement it properly. But I will give you a hint:

var combo = [null] #it's array for combo
if time_dict["action_time"] > 0.5 and time_dict["arrow_time"] > 0.5: 
		combo = [null, null, null, null, null] # It cleans array when you do nothing

if Input.is_action_pressed("ui_right"): #implementation for arrow
    		velocity.x += 1
    		last_arrow = "RIGTH" if side == "right" else "LEFT"
    		if time_dict["arrow_time"] > 0.05: # to be writen once in combo list 
    			combo.append(last_arrow)
    		time_dict["arrow_time"] = 0
    
if Input.is_action_just_pressed("HPunch"): #implementation for punches
    		HP = true
    		time_dict["action_time"] = 0
    		time_dict["HP_time"] = 0
    		last_pressed = "HP"
    		combo.append("HP")
    
func IS(): # implementation for ability (throwing ice ball)
    	if [combo[-3], combo[-2], combo[-1]] == ["DOWN", "RIGTH", "LP"] and ice_shot == false or $AnimatedSprite.animation == "iceside" and time_dict["IS_time"] < 0.8:
    		if time_dict["IS_time"] > 2:
    			time_dict["IS_time"] = 0
    			emit_signal("ice_go", ice, $Portal.global_position, side)
    			ice_shot = true
    		else:
    			ice_shot = false
    		$AnimatedSprite.play("iceside")
    	else: # I am using array for all abilities so if condition is false player can move and jump ect.
    		return true

I hope it makes sense:) and I hope it helps.