michaelm75au
Posts: 13089
Joined: 5/5/2001 From: Melbourne, Australia Status: offline
|
This isn't working as expected as a Condition now. Will need to have a closer look. Okay. I think the issue has come about with the off-the-grid contacts. Use the actual unit instead of the contact.
local x,y
local answer = false
local sidename = 'PLAN'
-- unit that triggered event
local contact = ScenEdit_UnitX()
--contact = ScenEdit_GetUnit({name='FFH 150 Anzac', guid='04b98bf1-2a6e-45d5-9a2a-5bd00a0e4cbe'})
local side = VP_GetSide( { side = sidename })
local rangeFrom = side.units
for i = 1, #rangeFrom do
-- unit base range on
local u = ScenEdit_GetUnit({ guid= rangeFrom[i].guid })
if u == nil then
return answer
end
-- distance between my base unit and the contact
local dist = u:rangetotarget( contact.guid)
if dist < 100 then
print('target in range (' .. dist ..'NM)')
--ScenEdit_SetSidePosture( ScenEdit_GetSideOptions({side=contact.side}).guid, side ,'H')
answer=true
else
print('target not in range (' .. dist ..'NM)')
end
end
return answer
< Message edited by michaelm75au -- 3/4/2018 12:29:38 AM >
_____________________________
Michael
|