er2.getSoldiersInArea 3
Get all alive soldiers within a specific radius from a specific position, ordered by the distance from the given position.
Notice: After a new soldier spawns or dies, this function might get a few instant before returning a correctly updated value.
Return value
Return Type | Description |
---|---|
Table | The script fills the Table given as parameter with the found soldiers, indexing it from 1,...,n ordered by distance from the given position and returns the filled table |
Parameters
Parameter | Type | Description |
---|---|---|
1 | vec3 | Center of the radial search |
2 | float | Radius where to search soldiers in |
3 | Table | A Lua initialized Table to fill with found soldiers |
Examples
--get a list of all soldiers arount pos 0,0,0 for 20 meters
local closeSoldiers = {} -- Create an empty table.
er2.getSoldiersInArea(vec3(0,0,0), 20, closeSoldiers); -- fill it with all soldiers currently alive
--print the name of each soldier
for key, soldier in pairs(closeSoldiers) do
print("Name: "..soldier.getName())
end