er2.getAllSoldiers 73

Get all alive soldiers.
Notice: After a new soldier spawns or dies, this function might get a few instant before returning a correctly updated value.


Return value

Return TypeDescription
voidThis function doesn't return anything

Parameters

ParameterTypeDescription
1TableA Lua initialized Table to fill with found soldiers

Examples

Example 43

--get a list of all soldiers in battle
local allSoldiers = {}  -- Create an empty table.
er2.getAllSoldiers(allSoldiers); -- fill it with all soldiers currently alive

--print the name of each soldier
for key, soldier in pairs(allSoldiers) do
    print("Name: "..soldier.getName())
end

Back to Scripting API