hedgewars/uScript.pas
changeset 4832 e55e2b6f59b0
parent 4780 8571151411b3
child 4850 434cd1284204
equal deleted inserted replaced
4831:57b46b5dbfff 4832:e55e2b6f59b0
    55     uVariables,
    55     uVariables,
    56     uCommands,
    56     uCommands,
    57     uUtils,
    57     uUtils,
    58     uKeys,
    58     uKeys,
    59     uCaptions,
    59     uCaptions,
    60     uDebug;
    60     uDebug,
       
    61     uCollisions;
    61 
    62 
    62 var luaState : Plua_State;
    63 var luaState : Plua_State;
    63     ScriptAmmoLoadout : shortstring;
    64     ScriptAmmoLoadout : shortstring;
    64     ScriptAmmoProbability : shortstring;
    65     ScriptAmmoProbability : shortstring;
    65     ScriptAmmoDelay : shortstring;
    66     ScriptAmmoDelay : shortstring;
   970     lc_getgearposition:= 2;
   971     lc_getgearposition:= 2;
   971 end;
   972 end;
   972 
   973 
   973 function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
   974 function lc_setgearposition(L : Plua_State) : LongInt; Cdecl;
   974 var gear: PGear;
   975 var gear: PGear;
       
   976     col: boolean;
   975     x, y: LongInt;
   977     x, y: LongInt;
   976 begin
   978 begin
   977     if lua_gettop(L) <> 3 then
   979     if lua_gettop(L) <> 3 then
   978         LuaError('Lua: Wrong number of parameters passed to SetGearPosition!')
   980         LuaError('Lua: Wrong number of parameters passed to SetGearPosition!')
   979     else
   981     else
   980         begin
   982         begin
   981         gear:= GearByUID(lua_tointeger(L, 1));
   983         gear:= GearByUID(lua_tointeger(L, 1));
   982         if gear <> nil then
   984         if gear <> nil then
   983             begin
   985             begin
       
   986             col:= gear^.CollisionIndex >= 0;
   984             x:= lua_tointeger(L, 2);
   987             x:= lua_tointeger(L, 2);
   985             y:= lua_tointeger(L, 3);
   988             y:= lua_tointeger(L, 3);
       
   989             if col then DeleteCI(gear);
   986             gear^.X:= int2hwfloat(x);
   990             gear^.X:= int2hwfloat(x);
   987             gear^.Y:= int2hwfloat(y);
   991             gear^.Y:= int2hwfloat(y);
   988             SetAllToActive;
   992             if col then AddGearCI(gear);
       
   993             SetAllToActive
   989             end
   994             end
   990         end;
   995         end;
   991     lc_setgearposition:= 0
   996     lc_setgearposition:= 0
   992 end;
   997 end;
   993 
   998