Why did my program lock up?
by Drethon · in Torque Game Builder · 05/06/2009 (5:21 pm) · 7 replies
I have the code below, Difference gets echoed as well as the difference which is 0 or false leading to else to get echoed.. Angling never gets echoed and neither does an echo at the end of the function.
What would cause the function to lock up at this point and not progress?
echo("Difference");echo(%distance < %this.range);
if ( %distance < %this.range )
{
%this.currentWaypoint = %this.currentWaypoint + 1 ;
if ( %this.currentWaypoint >= %this.totalWaypoints )
{
%this.currentWaypoint = 0 ;
}
}
else
{
echo("Else");
}
echo("Angling");
What would cause the function to lock up at this point and not progress?
echo("Difference");echo(%distance < %this.range);
if ( %distance < %this.range )
{
%this.currentWaypoint = %this.currentWaypoint + 1 ;
if ( %this.currentWaypoint >= %this.totalWaypoints )
{
%this.currentWaypoint = 0 ;
}
}
else
{
echo("Else");
}
echo("Angling");
#2
Though just to show the values going in:
Distance: 67.0521 is less than Range: 10
(or not less than)
05/06/2009 (6:17 pm)
I had an echo inside the first if statement and it never got hit...Though just to show the values going in:
Distance: 67.0521 is less than Range: 10
(or not less than)
#3
When I get a change to crank on it again tonight I'll start commenting out code blocks to narrow things down but can anyone tell me why this might be happening so I can understand it and avoid it in the future?
05/07/2009 (5:31 am)
What confuses me with this is that block of code has run fine in the past. A few lines down I had a divide by 0 issue which caused a lockup. After I addressed that issue, even though I didn't change any of the code posted, the function locked up where I mentioned.When I get a change to crank on it again tonight I'll start commenting out code blocks to narrow things down but can anyone tell me why this might be happening so I can understand it and avoid it in the future?
#4
05/07/2009 (8:10 am)
In my experience, code not getting executed is normally a syntax error (mismatched { or similar). Have you run torsion against it and stepped through?
#5
Currently I only have codeweaver, might be time to shell out a couple bucks to get torsion for debugging...
05/07/2009 (8:39 am)
Hmm, I had though the console would output an error whenever that happened. Perhaps I was mistaken.Currently I only have codeweaver, might be time to shell out a couple bucks to get torsion for debugging...
#6
05/07/2009 (6:15 pm)
Finally found it, it was a separate function call about twenty lines further on. I guess console writes can fail if the program crashes further on...
#7
05/07/2009 (6:29 pm)
Yep. I think the dump from console log in memory to console log on disk is probably cached and only occurs periodically. Either that, or the call to flush writes to disk, so they actually get written out, is probably periodic.
Torque Owner Johnny Sprada
For instance:
echo("Distance: ", %distance, " is less than Range: ", %this.range);You can drop that line inside the first if statement.