hedgewars/uScript.pas
changeset 4832 e55e2b6f59b0
parent 4780 8571151411b3
child 4850 434cd1284204
--- a/hedgewars/uScript.pas	Mon Jan 10 18:20:58 2011 +0300
+++ b/hedgewars/uScript.pas	Mon Jan 10 19:15:12 2011 -0500
@@ -57,7 +57,8 @@
     uUtils,
     uKeys,
     uCaptions,
-    uDebug;
+    uDebug,
+    uCollisions;
 
 var luaState : Plua_State;
     ScriptAmmoLoadout : shortstring;
@@ -972,6 +973,7 @@
 
 function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
 var gear: PGear;
+    col: boolean;
     x, y: LongInt;
 begin
     if lua_gettop(L) <> 3 then
@@ -981,11 +983,14 @@
         gear:= GearByUID(lua_tointeger(L, 1));
         if gear <> nil then
             begin
+            col:= gear^.CollisionIndex >= 0;
             x:= lua_tointeger(L, 2);
             y:= lua_tointeger(L, 3);
+            if col then DeleteCI(gear);
             gear^.X:= int2hwfloat(x);
             gear^.Y:= int2hwfloat(y);
-            SetAllToActive;
+            if col then AddGearCI(gear);
+            SetAllToActive
             end
         end;
     lc_setgearposition:= 0