Game Development Community

A little less robust?

by Dreamer · in Torque Game Engine · 06/02/2005 (4:37 pm) · 13 replies

I'm running into problems, when I create a new function and forget something say a quote or a semi colon etc and so forth.
This script will still compile and usually run, but that function I just added won't be properly compiled.
Is there ANY way to get Torque to stop compilation and execution on EVERY syntax error, so I can catch these problems early? Seems like there should be, I mean the engine IS aware of the problem it DOES put it in the log, I would just like to see an OnError(die) option or something of the sort.

Thanx.

NOTE: I realize this is probably the uber noob question of the year, but it's really begun to wear me down, only knowing there was a problem well into program execution.

#1
06/02/2005 (5:00 pm)
If there's a syntax error in your script, the script won't compile at all, you're mistaken.
What happends is that your dso file is read instead, and the changes you made since the dso was compiled will be ignored.
#2
06/02/2005 (5:05 pm)
@Stefan, yeah you would think wouldn't ya. Unfortunately, all my .dso files go in a directory, that I delete after each run, so yes the script itself MAY fail to compile, but since these are usually non-super critical functions I'm talking about here, having the script fail to compile isn't enough. What I need to do is completely stop the engine when this happens.
#3
06/02/2005 (5:18 pm)
...
#4
06/03/2005 (5:43 pm)
Haven't ever seen that before Dreamer. If my script is broken (due to syntax errors) and the .dso is gone, it won't compile the .cs file at all.
#5
06/03/2005 (9:54 pm)
Ok Stefan lemme make it a little clearer...
Yes the individual script may fail to compile but the program (what I've been reffering to as the script), will continue to run and just give abnormal results.
#6
06/03/2005 (10:48 pm)
@dreamer - try this .bat script (windows example)

echo off
cls
echo Deleting *.DSO files ...
del /S *.dso
echo Launching TORQUE.exe ...
torque

This is useful during development because if you delete the .dso files before running then, if the scripts fail to compile, you will no it because the game will quit or not launch.

What you are seeing probably is a script fails to compile so the engine just uses the next best thing- the previously compiled .dso. That's what I think I have seen anyways. Basically what stefan said.
#7
06/03/2005 (11:22 pm)
He has stated three times in this thread that No there are no .dso files to be loaded when the script compile fails.

Just because the script doesn't compile does not mean the engine does not load the functions that are defined in that file. It's not a common occurance, but yes it can happen.
#8
06/03/2005 (11:28 pm)
All I'm asking here folks is a way to kill the engine if there is a syntax error in the script, I don't care how it dies so long as it dies promptly. It seems silly to me that the thing will keep running (in a development environment anyways), regardless of something as serious as a syntax error.

Thanx for the help with cleaning up .dso files, I'll try to remember it next time I'm using a Windows box, in the meantime I'll just issue rm -rf ~/.garagegames on my Gnetoo box in between runs.
#9
06/03/2005 (11:30 pm)
@harold - how can the functions load if the script file didn't compile? Does the engine load functions like on a token by token basis? So if you have a syntax error on line 500 it loads whatever functions were up to there in the file? That's weird
#10
06/03/2005 (11:35 pm)
@dreamer - I haven't run Torque on linux. What's in .garagegames? Wouldn't it be better to do something like this?

rm 'find . -name "*.dso"'
#11
06/04/2005 (2:28 am)
@Alex, that would work fine too but mine works better ~/.garagegames is where all my dso's are automatically kept, so just deleting that single directory cleans them all instantly.
#12
06/04/2005 (2:42 am)
As Joseph mentioned you could add in a call at the end of the CMDerror() function. You could have it call a script function that you can define yourself, for example:

[scan.cc]
/* Add at end of CMDerror() function (approx line 1367 in scan.cc) */
Con::executef(this, 1, "onScriptSyntaxError");

[syntaxerror.cs]
function onScriptSyntaxError()
{
   echo("Shutdown due to script error");
   quit();
}

This would allow you to create an error handler script where you can do whatever you want. The downside is that if there are problems with this script it will not get picked up, but it shouldn't be too much trouble to make sure this script is correct as you only need to do it once! You just need to included syntaxerror.cs as soon as possible after startup. Doing the shutdown this way makes sure that the engine has an opportunity to close nicely.
#13
06/04/2005 (2:50 am)
Ah, yeah.. then Joseph's suggestion should work, at least in theory or as it seems here on 'paper'. Just make the engine break when it finds an error. I actually like this change myself, so I'll implement it myself.