get_friendlies_around_unit
The get_friendlies_around_unit function retrieves a list of friendly player units around a specified unit within a given distance. This function is useful for identifying and targeting friendly players in the vicinity of a unit.
Parameters
unit(string): The unit identifier (such as "player", "target", "focus", etc.) around which to search for friendly units.distance(number, optional): The maximum distance within which to search for friendly units. Defaults to 40 if not specified.
Returns
units(table): A table containing the identifiers of the friendly player units found within the specified distance.
Example Usage in Lua
Here is an example of how to use the get_friendlies_around_unit function in Lua:
local api = ...
-- Function to print the list of friendly player units around a specified unit
function PrintFriendliesAroundUnit(unit, distance)
local friendlies = api.get_friendlies_around_unit(unit, distance)
print("Friendly players around unit '" .. unit .. "' within distance " .. distance .. ":")
for _, friendly in ipairs(friendlies) do
print(friendly)
end
end
-- Example usage: Print the list of friendly player units around the player within a distance of 40
PrintFriendliesAroundUnit("player", 40)