COMMUNITY

Syntax error when compling

for some reason i try to compile and it gives me an expected } error on a specific line, and when i add that it gives me a bunch of errors.

error says source/PlayState.hx:3765: characters 2-8 : Expected }

line 3765 is the start of this function

	public function tetrisblockage(percentageBlockage:Int, duration:Int, instant:Bool = false)
		{
			canPause = false; //temp(hopefully) solution to people avoiding tetris blocking mechanic 
			var tetrisBlockagePiece:FlxSprite = new FlxSprite(0, -1080).loadGraphic(Paths.image('tetris/health_blockage'));
			tetrisBlockagePiece.cameras = [camHUD];
			tetrisBlockagePiece.antialiasing = false;

			tetrisBlockagePiece.x = healthBar.x + (healthBar.width * (FlxMath.remapToRange(100 - percentageBlockage, 0, 100, 100, 0) * 0.01)) - 240;
			tetrisBlockagePiece.y = -720;
			tetrisBlockagePiece.setGraphicSize(Std.int(tetrisBlockagePiece.width * 0.075));

			add(tetrisBlockagePiece);

			if(!instant)
				if (FlxG.save.data.downscroll)
					{
						tetrisBlockagePiece.y = 150;
						trace(tetrisBlockagePiece.y);
					}
				else
					{
						tetrisBlockagePiece.y = -1080;
						trace(tetrisBlockagePiece.y);
					}

In the code that appears above this function, did you miss adding an end brace } somewhere?

I would suggest adding brackets here. I normally try to keep it simple with if statements.

if( !instant ) doSomething();

or

( !instant )? doOnething(): doAnother();

or

if( !instant ){
   doSomething();
   doMore();
}

Would be very careful with indenting if’s without brackets with large amounts of code below.

you can us /* */ to hide sections of functions to help track down missing brackets by enabling and disabling sections of code till you find your error. Haxe is not always good with knowing where the missed closing bracket was expected… for obvious reasons if you think about it.