tweak take 2
authornemo
Tue, 13 Mar 2012 12:22:56 -0400
changeset 6780 166ee5275915
parent 6779 ccd8aecaff6d
child 6781 23f627ba8ee9
tweak take 2
hedgewars/uScript.pas
--- a/hedgewars/uScript.pas	Tue Mar 13 12:10:48 2012 -0400
+++ b/hedgewars/uScript.pas	Tue Mar 13 12:22:56 2012 -0400
@@ -1385,6 +1385,7 @@
 
 function lc_getgearvelocity(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
+var t: LongInt;
 begin
     if lua_gettop(L) <> 1 then
         begin
@@ -1397,9 +1398,10 @@
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
+            t:= hwRound(gear^.dX * 1000000);
             // gear dX determines hog orientation
-            if (gear^.dX.isNegative) and (gear^.dX = _0) then lua_pushinteger(L, -1)
-            else lua_pushinteger(L, hwRound(gear^.dX * 1000000));
+            if (gear^.dX.isNegative) and (t = 0) then t:= -1;
+            lua_pushinteger(L, t);
             lua_pushinteger(L, hwRound(gear^.dY * 1000000))
             end
         end;