Page 1 of 1

[1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Posted: Wed Mar 22, 2023 12:17 pm
by blu3s
Hi, I am trying to activate intermittent emissions on a unit, but I can't get it to work from lua.

This is the code:

Code: Select all

local unit = ScenEdit_AddUnit({type='Facility',guid='EXAMPLE-GUID', name='Radar',dbid=1006, side='RED',latitude=10,longitude=0})

ScenEdit_SetUnitIntermittentEmissionConfig( unit.guid, 'CUSTOM', { UseEmissionInterval=1, EmissionDuration=math.random(2,4)*60, EmissionInterval=math.random(5,10)*60, EmissionIntervalVariation=math.random(5,10)*60, WakeStance_UNFRIENDLY=1 } )
ScenEdit_SwitchUnitIntermittentEmission ( unit.guid, 'CUSTOM', 1 )
If you manually access the GUI and click on intermittent mode, it is already possible to activate and deactivate the behavior using the method:

Code: Select all

ScenEdit_SwitchUnitIntermittentEmission ( 'EXAMPLE-GUID', 'CUSTOM', 0 ) --to deactivate
ScenEdit_SwitchUnitIntermittentEmission ( 'EXAMPLE-GUID', 'CUSTOM', 1 ) --to activate
Since the method works once the step of activating the intermittent emission mode from the GUI is done, I don't know if I am missing some step in Lua or if there is a problem with that first switch.

Here you have a scen with the red side added,
Intermittent.zip
(4.04 KiB) Downloaded 21 times
First you run the first code, the unit is added but no intermittent emissions occur.

Second, you open the EMCON window of the unit and click on the 'Use custom preset only' checkbox and then in continuous mode, the radar starts to emit with the parameters set. If you then go to lua console and run the disable/enable code, it works fine.

Thank you

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Posted: Thu Mar 23, 2023 11:51 am
by Dimitris
Logged #14921

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Posted: Sun Apr 02, 2023 1:05 am
by michaelm75au
FYI for next build
To activate, use this on the unit wrapper:
unit.UseCustomIntermittentEmissionOnly = true

It is the equivalent to the button on the UI. And applies to the custom setting I'm told.

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Posted: Sun Apr 02, 2023 6:09 am
by blu3s
Thank you, Michael, really appreciated