Added getStaticObjectByID(), fixed bug in getSceneriesInZone()

This commit is contained in:
Ambroise Garel 2025-07-27 15:07:23 +02:00
parent 948cdf325f
commit 5d022d3edf

View File

@ -12,6 +12,7 @@
-- DCSEx.world.getGroupByID(groupID)
-- DCSEx.world.getNextMarkerID()
-- DCSEx.world.getSceneriesInZone(center, radius, minHealth)
-- DCSEx.world.getStaticObjectByID(staticID)
-- DCSEx.world.getTerrainHeightDiff(coord, searchRadius)
-- DCSEx.world.getUnitByID(unitID)
-- DCSEx.world.isGroupAlive(g, unitsMustBeInAir)
@ -342,7 +343,7 @@ do
local scenerySearchvolume = {
id = world.VolumeType.SPHERE,
params = { point = { x = center.x, y = 0, z = center.y }, radius = radius }
params = { point = DCSEx.math.vec2ToVec3(center, "land"), radius = radius }
}
local function ifSceneryFound(foundScenery, val)
@ -360,6 +361,23 @@ do
return sceneries
end
-------------------------------------
-- Searches and return a static object by its ID
-- @param staticID ID of the static object
-- @return An unit, or nil if no static object with this ID was found
-------------------------------------
function DCSEx.world.getStaticObjectByID(staticID)
for coalitionID = 1, 2 do
for _, s in pairs(coalition.getStaticObjects(coalitionID)) do
if DCSEx.dcs.getObjectIDAsNumber(s) == staticID then
return s
end
end
end
return nil
end
-- TODO: description, update file header
function DCSEx.world.getTerrainHeightDiff(coord, searchRadius)
local samples = {}