diff --git a/Script/DCS extensions/World.lua b/Script/DCS extensions/World.lua index 982e716..eb06dc0 100644 --- a/Script/DCS extensions/World.lua +++ b/Script/DCS extensions/World.lua @@ -16,6 +16,7 @@ -- DCSEx.world.getMarkerByText(text, coalition) -- DCSEx.world.getNextMarkerID() -- DCSEx.world.getPlayersInAir(side) +-- DCSEx.world.getPlayersOnGround(side) -- DCSEx.world.getSceneriesInZone(center, radius, minHealth) -- DCSEx.world.getSpawnPoint(zone, surfaceType, safeRadius) -- DCSEx.world.getStaticObjectByID(staticID) @@ -328,6 +329,30 @@ do return playersInAir end + ------------------------------------- + -- Returns a table of all player units currently NOT in the air (on ramp/ground/runway) + ------------------------------------- + -- @param side Coalition the players must belong to, or nil to search all coalitions + -- @return A table of player objects + ------------------------------------- + function DCSEx.world.getPlayersOnGround(side) + local players = {} + if side then + players = coalition.getPlayers(side) + else + players = DCSEx.world.getAllPlayers() + end + + local playersOnGround = {} + for _,p in ipairs(players) do + if not p:inAir() then + table.insert(playersOnGround, p) + end + end + + return playersOnGround + end + ------------------------------------- -- Returns a valid spawn point for a ground unit (not stuck in trees, buildings...) or a naval unit -------------------------------------