I don't know if this is the right place to ask, but I've tried to create a small script that explodes all planes that are not inside a specific zone. The only problem that I have is that I can't get a table of DCS units.
do
trigger.action.outText("loop ", .5, false)
net.log("loop")
local ZONE_NAME = "Zone"
local allUnits = mist.makeUnitTable({'[plane]'})
local unitsInsideZone = mist.getUnitsInZones(allUnits, ZONE_NAME)
-- check all units are inside zone
for _, unit in pairs(allUnits) do
trigger.action.outText("checking "..unit:getName(), 2, false)
end
end
I tried this, but DCS gives me the error
at line `trigger.action.outText("checking "..unit:getName(), 2, false)`.
After further investigation I found out that `unit` seems to be a string value. I tried searching on different forums, but they all say that this should work. The mist documentation even gives me this exact line:
do
local units = mist.makeUnitTable({'[all]'}, 'static')
end
I don't know what I'm doing wrong.
Edit
I got it working by 'borrowing' some code from Outofmyzone:
enemyPlanes = mist.makeUnitTable({'[all][planes]'})
InZone = mist.getUnitsInZones(enemyPlanes, {zone})
for i = 1, #enemyPlanes do
uName = enemyPlanes[i]
unit = Unit.getByName(uName)
end