Game Development Community

TorqueScript subtraction oddity

by Colin Nickerson · in Torque 3D Professional · 08/24/2013 (7:25 pm) · 3 replies

Hello,

Would it be possible to look into whether or not this is as designed?

Version One

%dt = getRealTime() - %this.lastTime;
// dt == -1


Version Two

%time = getRealTime();
%dt = %time - %this.lastTime;
// Correct result


This just threw me through a bit of a loop, especially since Torison handles Version One as expected in its watch window.

Thanks
Colin

#1
08/24/2013 (9:22 pm)
Did you try surrounding getRealTime() in parentheses for that first example? Torquescript might just be parsing this wrong.
#2
08/25/2013 (6:35 pm)
I highly doubt that was as designed. Can you do a test with another function that's not getRealTime? Not sure why it would hake a difference, but hey. Maybe test it with another built-in engine function as well as a function you've defined yourself in scripts.
#3
08/26/2013 (8:45 am)
First time through the loop the term %this.lastTime has no value. Initialize %this.lasttime = getRealTime() before you call any subsequent functions.