GetEMCON?

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

GetEMCON?

Post 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.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: GetEMCON?

Post 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. :o
Michael
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: GetEMCON?

Post 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.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: GetEMCON?

Post 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
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: GetEMCON?

Post by vonotha »

Great! Hope more users will find it useful :)

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: GetEMCON?

Post 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

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
Post Reply

Return to “Lua Legion”