Skip to content

friends

The friends function retrieves a list of friendly units within a specified distance from the player. This function is useful for identifying and targeting friendly units in the vicinity of the player.

Parameters

  • distance (number, optional): The maximum distance within which to search for friendly units. Defaults to 40 if not specified.

Returns

  • valid_objects (table): A table containing the identifiers of the friendly units found within the specified distance.

Example Usage in Lua

Here is an example of how to use the friends function in Lua:

local api = ...

-- Function to print the list of friendly units within a specified distance from the player
function PrintFriends(distance)
    local friends = api.friends(distance)
    print("Friends within distance " .. distance .. ":")
    for _, friend in ipairs(friends) do
        print(friend)
    end
end

-- Example usage: Print the list of friendly units within a distance of 40 from the player
PrintFriends(40)