[1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission
Posted: Wed Mar 22, 2023 12:17 pm
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:
If you manually access the GUI and click on intermittent mode, it is already possible to activate and deactivate the behavior using the method:
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,
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
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 )
Code: Select all
ScenEdit_SwitchUnitIntermittentEmission ( 'EXAMPLE-GUID', 'CUSTOM', 0 ) --to deactivate
ScenEdit_SwitchUnitIntermittentEmission ( 'EXAMPLE-GUID', 'CUSTOM', 1 ) --to activate
Here you have a scen with the red side added,
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