hedgewars/uScript.pas
changeset 8012 2a61631a4505
parent 7996 66e8ac9c2274
child 8025 07862ab415c8
child 8026 4a4f21070479
equal deleted inserted replaced
8011:ffd5eba8f7c2 8012:2a61631a4505
  1725     if lua_gettop(L) <> 1 then
  1725     if lua_gettop(L) <> 1 then
  1726         LuaError('Lua: Wrong number of parameters passed to HideHog!')
  1726         LuaError('Lua: Wrong number of parameters passed to HideHog!')
  1727     else
  1727     else
  1728         begin
  1728         begin
  1729         gear:= GearByUID(lua_tointeger(L, 1));
  1729         gear:= GearByUID(lua_tointeger(L, 1));
  1730         hiddenHedgehogs[hiddenHedgehogsNumber]:=gear^.hedgehog;
  1730         HideHog(gear^.hedgehog)
  1731         inc(hiddenHedgehogsNumber);
       
  1732         HideHog(gear^.hedgehog);
       
  1733         end;
  1731         end;
  1734     lc_hidehog := 0;
  1732     lc_hidehog := 0;
  1735 end;
  1733 end;
  1736 
  1734 
  1737 function lc_restorehog(L: Plua_State): LongInt; Cdecl;
  1735 function lc_restorehog(L: Plua_State): LongInt; Cdecl;
  1738 var hog: PHedgehog;
  1736 var hog: PHedgehog;
  1739     i, j: LongInt;
  1737     i, h: LongInt;
       
  1738     uid: LongWord;
  1740 begin
  1739 begin
  1741     if lua_gettop(L) <> 1 then
  1740     if lua_gettop(L) <> 1 then
  1742         LuaError('Lua: Wrong number of parameters passed to RestoreHog!')
  1741         LuaError('Lua: Wrong number of parameters passed to RestoreHog!')
  1743     else
  1742     else
  1744         begin
  1743         begin
  1745           i := 0;
  1744         uid:= LongWord(lua_tointeger(L, 1));
  1746           while (i < hiddenHedgehogsNumber) do
  1745         if TeamsCount > 0 then
  1747             begin
  1746             for i:= 0 to Pred(TeamsCount) do
  1748             if hiddenHedgehogs[i]^.gearHidden^.uid = LongWord(lua_tointeger(L, 1)) then
  1747                 for h:= 0 to cMaxHHIndex do
  1749               begin
  1748                     if (TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil) and (TeamsArray[i]^.Hedgehogs[h].GearHidden^.uid = uid) then
  1750                 hog := hiddenHedgehogs[i];
  1749                         begin
  1751                 RestoreHog(hog);
  1750                         RestoreHog(@TeamsArray[i]^.Hedgehogs[h]);
  1752                 dec(hiddenHedgehogsNumber);
  1751                         exit(0)
  1753                 for j := i to hiddenHedgehogsNumber - 1 do
  1752                         end
  1754                   hiddenHedgehogs[j] := hiddenHedgehogs[j + 1];
       
  1755                 lc_restorehog := 0;
       
  1756                 exit;
       
  1757               end;
       
  1758             inc(i);
       
  1759             end;
       
  1760         end;
  1753         end;
  1761     lc_restorehog := 0;
  1754     lc_restorehog := 0;
  1762 end;
  1755 end;
  1763 
  1756 
  1764 // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)
  1757 // boolean TestRectForObstacle(x1, y1, x2, y2, landOnly)