share/hedgewars/Data/Scripts/Tracker.lua
changeset 14230 8edbdd3a1fe7
parent 11733 67049c8dedd1
child 14231 74bf2d906097
equal deleted inserted replaced
14229:e590fb0f2567 14230:8edbdd3a1fe7
    32         end
    32         end
    33     end
    33     end
    34     if trackingTeams and GetGearType(gear) == gtHedgehog then
    34     if trackingTeams and GetGearType(gear) == gtHedgehog then
    35     	hogs = teams[GetHogTeamName(gear)]
    35     	hogs = teams[GetHogTeamName(gear)]
    36         if hogs ~= nil then
    36         if hogs ~= nil then
    37             if table.maxn(hogs) == 1 then
    37             if #hogs == 1 then
    38                 hogs = nil
    38                 hogs = nil
    39             else
    39             else
    40 				for k, hog in ipairs(hogs) do
    40 				for k, hog in ipairs(hogs) do
    41                     if hog == gear then
    41                     if hog == gear then
    42                         table.remove(hogs, k)
    42                         table.remove(hogs, k)
    87 	
    87 	
    88     if trackingTeams then
    88     if trackingTeams then
    89     	hogs = teams[GetHogTeamName(gear)]
    89     	hogs = teams[GetHogTeamName(gear)]
    90     	
    90     	
    91         if hogs ~= nil then
    91         if hogs ~= nil then
    92             if table.maxn(hogs) == 1 then
    92             if #hogs == 1 then
    93                 hogs = nil
    93                 hogs = nil
    94             else
    94             else
    95                 for k, hog in ipairs(hogs) do
    95                 for k, hog in ipairs(hogs) do
    96                     if hog == gear then
    96                     if hog == gear then
    97                         table.remove(hogs, k)
    97                         table.remove(hogs, k)
   284     end
   284     end
   285 end
   285 end
   286 
   286 
   287 -- Run a function on hogs in a clan
   287 -- Run a function on hogs in a clan
   288 function runOnHogsInClan(func, clan)
   288 function runOnHogsInClan(func, clan)
   289     for i = 1, table.maxn(clans) do
   289     for i = 1, ClansCount do
   290         if clans[i] == clan then
   290         if clans[i] == clan then
   291             for k, hog in ipairs(teams[i]) do
   291             for k, hog in ipairs(teams[i]) do
   292                 func(hog)
   292                 func(hog)
   293             end
   293             end
   294         end
   294         end
   295     end
   295     end
   296 end
   296 end
   297 
   297 
   298 -- Run a function on hogs in other clans
   298 -- Run a function on hogs in other clans
   299 function runOnHogsInOtherClans(func, clan)
   299 function runOnHogsInOtherClans(func, clan)
   300     for i = 1, table.maxn(clans) do
   300     for i = 1, ClansCount do
   301         if clans[i] ~= clan then
   301         if clans[i] ~= clan then
   302             for k, hog in ipairs(teams[i]) do
   302             for k, hog in ipairs(teams[i]) do
   303                 func(hog)
   303                 func(hog)
   304             end
   304             end
   305         end
   305         end