Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code not working anymore cause continue not supported in gdscript 2 #75093

Closed
HamidKazemzadeh opened this issue Mar 19, 2023 · 4 comments
Closed

Comments

@HamidKazemzadeh
Copy link

HamidKazemzadeh commented Mar 19, 2023

Godot version

4.0 stable

System information

windows 10

Issue description

I have a code for finite state machine that use match to change state and after changing state use continue to skip current state codes and jump to next state, but in gdscript2 continue doesn't work the same way as before, so my code doesn't work anymore and I don't know what is the replacement for "continue" to make it work

Steps to reproduce

match currentState:
		STATES.AIR:
			sprite.play("jump")	
			
			if is_on_floor() and velocity.y == 0:
				currentState=STATES.FLOOR
				#! lastJumpDirection = 0
				continue
			elif is_near_wall():
				currentState = STATES.WALL
				continue
			elif should_climb_ladder():
				currentState = STATES.LADDER
				continue
			# Add the gravity.
			velocity.y += gravity * delta

Minimal reproduction project

N/A

@AThousandShips
Copy link
Member

AThousandShips commented Mar 19, 2023

If you want to do a continue to move to the next statement in the match this is indeed no longer supported, it was removed here #71914, and here is the proposed future feature to replace it godotengine/godot-proposals#4775

I don't think there's any direct way to do this in the current version of GDScript though

@AThousandShips
Copy link
Member

AThousandShips commented Mar 19, 2023

But please for issues that aren't bugs but instead questions, please turn to the community channels as this is for bugs only

@dalexeev
Copy link
Member

I agree. This is not a bug, but an intentional change. There was a suggestion to replace it with some new keyword, but we did not find a word that conveys the exact meaning of the old behavior (for example, fallthrough means a little different). Also, the ability to jump to a different match branch often results in less readable code.

@Calinou
Copy link
Member

Calinou commented Jun 22, 2023

Closing per the above comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants