Game Development Community

Syntax checking and me.

by Ben Batstone-Cunningham · in Torque Game Builder · 05/22/2005 (10:57 pm) · 5 replies

Hi, I grabbed this after I saw it announced a GDC - it looks like a lot of fun.

Right now I am running throught he tutorial, and having a slow time of it. I learn best when I actually type in the stuff I read on the page, so I'm entering all the example code by hand. This leads to the occaisional syntax bug, which is hard, because I'm having trouble finding an editor that can check it for me.

Right now I am stuck trying to make my ship STOP going up - I can't see any obvious errors and staring at my code for the last half hour is making me grumpy.

I've seen lots of mention in these forum of good editors, but where would I find good plugins or whatever else I need to make syntax checking easy? Right now, I'd settle for a trained monkey as long as it can give me a line number.

Ben

#1
05/22/2005 (11:44 pm)
When you fire up T2D hit the console key ("~" tilde) and scroll through the console for any red text. T2D will put two "#" by a syntax error in bright red text :)
#2
05/23/2005 (12:00 am)
And if you get stuck, post the code that's giving you grief. Someone here will probably be able to spot the problem and help you out.
#3
05/23/2005 (1:40 am)
Ooo, that helps a lot. There might be newer docs than the ones I have (rev 1.1) but if not, I would suggest mentioning that in the first few paragraphs.


But there is something weirder going on - the console reports as follows:

T2D/client/client.cs Line:121 - Syntax error.
>>> Advanced script error report. Line 241.
>>> Some error context, with ## on sides of error halt:
function playerUp()
{
^//Move player up
^$player.setLinearVelocityY( - ##)##;
}

function playerStopUp()
{
^player.setLinearVelocityY( 0 );
}
>>> Error report complete.

That is almost a copy and paste of the stuff in the tut. In order to make sure there was not something strange happening when because I changed the comment, I copied and pasted the relavant bits from the tut. Same error. As far as I can tell, all of my code is parenth matched up - but for anyone curious:

function setupT2DScene()
{
	
	// Create fxSceneGraph2D.
	new fxSceneGraph2D(t2dSceneGraph);
	
	// Associate Scenegraph with Window.
	sceneWindow2D.setSceneGraph( t2dSceneGraph );
	
	// Set Camera Position to be centered on (0,0) with
	// view width/height of (100/80).
	sceneWindow2D.setCurrentCameraPosition( "0 0 100 75" );
 	
	// begin tutorial code
	datablock fxImageMapDatablock2D(playershipImageMap)
	{
		mode = full;
		textureName = "~/client/images/playerShip";
	};
	
	datablock fxImageMapDatablock2D(enemyship1ImageMap)
	{
		mode = full;
		texturename = "~/client/images/enemyship1";
	};

	$player = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
	$player.setPosition("-35 0");
	$player.setSize( "14 7" );
	$player.setImageMap( playershipImageMap );

	%enemy = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
	%enemy.setSize( "14 7" );
	%enemy.setPosition( "40 0" );
	%enemy.setImageMap( enemyship1ImageMap );

	//movement
	%enemy.setLinearVelocityX(-20);

	// Create a new action map.
	new ActionMap(playerMap);
	// Bind keys to actions.
	playerMap.bindCmd(keyboard, "w", "playerUp();", "playerUpStop();");
	playerMap.bindCmd(keyboard, "s", "playerDown();", "playerDownStop();");
	playerMap.bindCmd(keyboard, "a", "playerLeft();", "playerLeftStop();");
	playerMap.bindCmd(keyboard, "d", "playerRight();", "playerRightStop();");
	playerMap.bindCmd(keyboard, "space", "playerFire();", "");
	// Activate the action map.
	playerMap.push();
}

function playerUp()
{
	//Move player up
	$player.setLinearVelocityY( - );
}

function playerUpStop()
{ 
	$player.setLinearVelocityY( 0 );

}

function playerDown()
{
	$player.setLinearVelocityY(  );
}

function playerDownStop()
{
	$player.setLinearVelocityY( 0 );
}
#4
05/23/2005 (2:23 am)
Change these bits of code:
function playerUp()
{
   //Move player up
   $player.setLinearVelocityY( - );
}

function playerDown()
{
   $player.setLinearVelocityY(  );
}

Into:
function playerUp()
{
   //Move player up
   $player.setLinearVelocityY( -10 );
}

function playerDown()
{
   $player.setLinearVelocityY( 10 );
}

But, it sounds like you're using an old version of T2D. Redownload the files. That error has been corrected in the current version of the tutorial (v1.3).

Edited to clarify changes needed.
#5
05/23/2005 (8:30 am)
OK, you guys are awesome. This is what I get for waiting two months before I play with it. Is there anyway to quickly check if there is a newer version of T2D that exists? I skimmed the news page last night to see if I should update, but I didn't see anything obvious.

thanks again,
bbc