UserFunction; SobGroup_GetDistanceToSobGroup - HWRM/KarosGraveyard GitHub Wiki
SobGroup_GetDistanceToSobGroup(<sg_Group1>, <sg_Group2>)
This simple little function returns the distance between two sobGroups. It can be useful when you need to assess the relative distance of ships/squadrons with a given space object. -SunTzu
-- The function returns the distance between two sobGroups (as an integer); it returns nil if either of the sobGroups is empty
-- Arguments: <sg_Group1> and <sg_Group2>, names of the sobGroups
function SobGroup_GetDistanceToSobGroup(sg_Group1, sg_Group2)
if SobGroup_Empty(sg_Group1) == 0 and SobGroup_Empty(sg_Group2) == 0 then
local t_position1 = SobGroup_GetPosition(sg_Group1)
local t_position2 = SobGroup_GetPosition(sg_Group2)
local li_distance = floor(sqrt((t_position1[1] - t_position2[1])*(t_position1[1] - t_position2[1]) + (t_position1[2] - t_position2[2])*(t_position1[2] - t_position2[2]) + (t_position1[3] - t_position2[3])*(t_position1[3] - t_position2[3])))
return li_distance
else
return nil
end
end
Updated Formatting? Initial
Updated for HWRM? Initial