Game Development Community

Showing script Errors outside the console

by John Cooney · in Torque Game Engine · 11/15/2005 (1:41 pm) · 3 replies

I don't know if this has been an issue for you guys, but it has plagued us.

When we're making changes to scripts (tweaking physics, damage, etc.) sometimes we'll accidentally add syntax errors, but never notice it. If the engine hits a syntax error while compiling the bytecode, it just uses the old dso, and goes merrily on its way.

Unless you read the console log, and scroll up to where the scripts are loaded, a syntax error can go completely unnoticed. This means that, while you're tweaking things, you just end up thinking, "Well, that change didn't make any difference. Maybe I need to double or triple that change!"

The best solution is to become more observant programmers, and make sure to check the log more regularly. But in lieu of better habits, I've added a visible warning.

So here's what I did, just above the printf function in Console.cc

static bool gSyntaxErrors = false;

Then, inside the printf function, just after the dvsprintf call, I added the following line:

if (dStrstr(buffer,"Syntax error.")) 
	   gSyntaxErrors = true;

For thoroughness, I put in an accessor:

bool SyntaxErrorsFound()
{
	return gSyntaxErrors;
}

Then, I just make a call to the accessor in my DebugHud:

if (Con::getSyntaxErrorsFound()) 
	{
		SetTextLine( 0, "Syntax Errors in Script!!" );
	}

BTW, don't worry too much about the DebugHud. I think that's one that we wrote ourselves (just a HUD with a textbox in it). The important thing is being able to tell that there are syntax errors in the script.

This may not be the best way to go about it, and it could certainly be developed to give more useful information (what line of the console log can you find these errors? What exactly are the errors? What about warnings? etc.) But for us, the most important thing was the psychological reminder that we should check the log, at times when it really needs to be checked.

Hope it's helpful for you guys.

#1
11/15/2005 (2:03 pm)
Hi,

cool idea, other way I saw is to delete all dsofiles with a batch before compilingg ...

berndt
#2
11/15/2005 (3:47 pm)
Torque 1.4's console window has a compile error list in a drop down underneath the textbox which does a similar thing.
#3
11/15/2005 (5:07 pm)
Something tells me the 1.4 is going to be pretty freaking sweet. I keep hearing about these great additions.

Well, I look forward to chucking this cheezy hack in favor of the good stuff. Thanks!