Page 1 of 1
GetEMCON?
Posted: Sat Jan 21, 2023 11:18 pm
by vonotha
There is SetEMCON function. But what about GetEMCON?
Context: SetEMCON can be used to both activate and deactivate the radar. However, there is no (easy) way for checking what is the current state of the radar.
Re: GetEMCON?
Posted: Sun Jan 22, 2023 1:58 am
by michaelm75au
Mmm. I'll look to see if that can be added to the SE_GetDoctrine() as that should be where it is. There is code for it but it wasn't implemented; probably an oversight on my part.

Re: GetEMCON?
Posted: Fri Jan 27, 2023 10:03 am
by vonotha
Thanks in advance!
Just to clarify, I was thinking about individual units rather than all the side units. In my mind, Doctrine applies to a side.
Re: GetEMCON?
Posted: Sun Jan 29, 2023 12:05 am
by KnightHawk75
vonotha wrote: Fri Jan 27, 2023 10:03 am
Thanks in advance!
Just to clarify, I was thinking about individual units rather than all the side units. In my mind, Doctrine applies to a side.
Should be in build 1307.1+ now
Re: GetEMCON?
Posted: Sun Jan 29, 2023 11:21 pm
by vonotha
Great! Hope more users will find it useful

Re: GetEMCON?
Posted: Thu Feb 02, 2023 9:06 pm
by vonotha
Till the time we get 'GetEMCON", a solution for checking EMCON state I've been using:
Code: Select all
function GetActiveSensors( unit_guid )
unit = ScenEdit_GetUnit({guid=unit_guid})
active_sensors = {}
for k, v in pairs(unit.sensors) do
if v.sensor_isactive then
table.insert(active_sensors, v)
end
end
return active_sensors
end
-- example:
-- {name='Radar (Big Bird D [91N6])', guid='C5TQUD-0HMO3V8H0RBCQ'}
-- unit_guid = 'C5TQUD-0HMO3V8H0RBCQ'
-- print(GetActiveSensors(unit_guid))
-- [91N6]', sensor_isactive = 'Yes', sensor_maxrange = 325, sensor_type = 2001 } }
-- returns true / false
function IsActive( unit_guid )
res = false
active_sensors = GetActiveSensors(unit_guid)
if array_len(active_sensors) > 0 then
res = true
end
return res
end
where array_len:
Code: Select all
--- array_len - table.getn/maxn equivalent
function array_len(array)
n = 0
for i, x in ipairs(array) do
n = n+1
end
return n
end