[1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Post bug reports and ask for game support here.

Moderator: MOD_Command

Post Reply
User avatar
blu3s
Posts: 1396
Joined: Fri Jul 08, 2022 9:45 am

[1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Post 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
Dimitris
Posts: 16050
Joined: Sun Jul 31, 2005 10:29 am
Contact:

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Post by Dimitris »

Logged #14921
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Post 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.
Michael
User avatar
blu3s
Posts: 1396
Joined: Fri Jul 08, 2022 9:45 am

Re: [1307.9] Lua ScenEdit_SwitchUnitIntermittentEmission

Post by blu3s »

Thank you, Michael, really appreciated
Post Reply

Return to “Tech Support”