": expected at end of line." in match statement

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

In my code I am trying to create transitions for some new animations in a match statement. Adding anything after states.fall gives me the ": expected at end of line." error.

I tried playing around with my code formatting but to no avail.

Here’s the full function:

func _get_transition(delta):
	match state:
		#inactive state transistions
		states.idle:
			if !parent.is_on_floor():
				if parent.motion.y < 0:
					return states.jump
				elif parent.motion.y > 0:
					return states.fall
			elif parent.motion.x > parent.move_speed - 128 or parent.motion.x < -parent.move_speed + 128:
				return states.run

		states.run:
			if !parent.is_on_floor():
				if parent.motion.y < 0:
					return states.jump
				elif parent.motion.y > 0:
					return states.fall
			elif parent.motion.x < parent.move_speed - 128 and parent.motion.x > -parent.move_speed + 128:
				return states.idle

		states.jump:
			if parent.is_on_floor():
				return states.idle

			elif parent.motion.y >= 0:
				return states.fall

		states.fall:
			if parent.is_on_floor():
				return states.idle

			elif parent.motion.y <= 0:
				return states.jump
		
		#1h active state transitions
		states.1h_run:	
			if combat_mode == true:
                            return states.1h_run
	
	return null

Are you missing some code? There’s a missing statement after

states.1h_run:  
    if combat_mode == true:

Bernard Cloutier | 2021-12-17 15:05

:bust_in_silhouette: Reply From: MoonlightVista

Weirdly enough, adding an underscore to the beginning of the dictionary values made the error go away.