Page 1 of 1
EMCON inherit question
Posted: Tue Dec 29, 2020 12:50 pm
by Gunner98
I believe that this is related to EMCON inherit.
I want to bring on a radar and turn it to active:
ScenEdit_AddUnit({type ='Facility', unitname ='R1/798 Msl Regt', dbid =1651, side ='WP', latitude='68.7562226777923', longitude='27.557318553208'})
ScenEdit_SetEMCON('Unit','R1/798 Msl Regt','Inherit=false;Radar=Active')
The problem is that the side doctrine is passive and I want to override this for this unit only. The script above was a stab, played around with it a bit but it doesn't work.
I see some scripts on this forum that allow turning radars on and off on timers and such but this one is pretty simple I think. Any ideas?
Tx
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 1:28 pm
by boogabooga
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 3:40 pm
by Gunner98
Yeah, looking to uncheck the box via lua on a unit that has just been added.
Tx
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 8:43 pm
by KnightHawk75
ORIGINAL: Gunner98
Yeah, looking to uncheck the box via lua on a unit that has just been added.
Tx
Which?
Your sample should do that on the unit object, uncheck the inherit parent and activate all radars. It does for me (I have red and blue sides). Are you sure you have the side name correct and no naming conflicts.
local u = ScenEdit_AddUnit({type ='Facility', unitname ='R1/798 Msl Regt', dbid =1651, side ='Red', latitude='68.7562226777923', longitude='27.557318553208'})
ScenEdit_SetEMCON('Unit',u.guid,'Inherit=false;Radar=Active')
Or do you mean uncheck the 'obey emcon' and manual modify specific sensors?
local uObj = SE_GetUnit({guid=xyzabc-123xxxxxxxx});
uObj.obeyEMCON = true; --checked
uObj.obeyEMCON = false; --unchecked, make sure it's done before you attempt to actually modify an individual sensor(s)
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 8:53 pm
by Gunner98
local uObj = SE_GetUnit({guid=xyzabc-123xxxxxxxx});
uObj.obeyEMCON = true; --checked
uObj.obeyEMCON = false; --unchecked, make sure it's done before you attempt to actually modify an individual sensor(s)
OK I think this is what I need. Will give it a shot.
I did try the obeyEMCON as a paramater in the ScenEdit_AddUnit command but that did not seem to work.
Thanks
B
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 9:14 pm
by Gunner98
OK that successfully gets the 'obey EMCON' box unchecked
But now the command to set the radar to active is not working..
ScenEdit_AddUnit({type ='Facility', unitname ='R1/798 Msl Regt', dbid =1651, side ='WP', latitude='68.7562226777923', longitude='27.557318553208'})
local uObj = SE_GetUnit({side = 'WP', name='R1/798 Msl Regt'});
uObj.obeyEMCON = false;
ScenEdit_SetEMCON('Unit', 'R1/798 Msl Regt','Radar=Active')
I've tried making the SetEMCON local and referencing 'uObj' but that returns errors.
Tx
RE: EMCON inherit question
Posted: Tue Dec 29, 2020 11:54 pm
by KnightHawk75
ORIGINAL: Gunner98
OK that successfully gets the 'obey EMCON' box unchecked
But now the command to set the radar to active is not working..
ScenEdit_AddUnit({type ='Facility', unitname ='R1/798 Msl Regt', dbid =1651, side ='WP', latitude='68.7562226777923', longitude='27.557318553208'})
local uObj = SE_GetUnit({side = 'WP', name='R1/798 Msl Regt'});
uObj.obeyEMCON = false;
ScenEdit_SetEMCON('Unit', 'R1/798 Msl Regt','Radar=Active')
I've tried making the SetEMCON local and referencing 'uObj' but that returns errors.
Tx
Actually it's doing exactly what you told it to do there. Since you told it _not_ to obey the setting you then gave it.

Again if all you are trying to do is add a unit and turn it active you're original sample works fine for me so something else is wrong.
Code: Select all
local u = ScenEdit_AddUnit({type ='Facility', unitname ='R1/798 Msl Regt', dbid =1651, side ='WP', latitude='68.7562226777923', longitude='27.557318553208'})
ScenEdit_SetEMCON('Unit',u.guid,'Inherit=false;Radar=Active')

^^ works perfectly fine for me for adding the unit, and turning off inheritance, and turning on all radars on the unit.
(are you letting the scene run for a split second after?, sometimes you need that for the radar to activate)
You didn't answer which it was you were trying to do though, ^ that ^ or manually screwing with specific individual sensors manually (ie the equivalent of unchecking inheritance, unchecking obey-emcon in the sensors window, and then manually flipping certain sensors on and keeping certain sensors off), which it does not sound like you are trying to do. The obeyEMCON part was for if were and there is more to it after that to flip a given sensor on\off, I can get into that but since I don't think that's what you're trying to do I'll pause to avoid confusion.
RE: EMCON inherit question
Posted: Wed Dec 30, 2020 1:53 pm
by Gunner98
Hmmm
So what I am trying to do is simply bring a unit on and turn on its radar. I did not let the scenario run for a few seconds following the test but will try that next.
I also note that you've made it local and referred to the guid. I'm bringing this radar on with about 28 other units and hadn't thought of using the local command.
This one is easy enough to isolate and perhaps that will make a difference as well.
Thanks
B
RE: EMCON inherit question
Posted: Wed Dec 30, 2020 2:22 pm
by Gunner98
OK thanks....
Letting the scenario run for a couple seconds did it.... [8|]
Both options - using local or not - work the same.
note to self - test in an isolated scenario not a monster one where you don't want to keep running the timer...
B
RE: EMCON inherit question
Posted: Wed Dec 30, 2020 10:17 pm
by KnightHawk75
Glad you got it sorted.[:)]
using local or not
Yes they work the same... (all other things being equal) for this particular thing.
Using u.guid instead of hard-coded name is just habit since so often I'm doing unit adds etc inside loops, avoids a potential issue and one less place to have to change a name or adjust if the name is a sequence, and I'm usually doing other stuff to the unit post creation so it's handy to already already have a handle stored to the unit just created.