EMCON inherit question

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

EMCON inherit question

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
boogabooga
Posts: 988
Joined: Wed Jul 18, 2018 12:05 am

RE: EMCON inherit question

Post by boogabooga »

The boogabooga doctrine for CMO: Any intentional human intervention needs to be able to completely and reliably over-ride anything that the AI is doing at any time.
User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: EMCON inherit question

Post by Gunner98 »

Yeah, looking to uncheck the box via lua on a unit that has just been added.

Tx
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: EMCON inherit question

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


User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: EMCON inherit question

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: EMCON inherit question

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: EMCON inherit question

Post 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') 
 
Image
^^ 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.
User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: EMCON inherit question

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
User avatar
Gunner98
Posts: 5967
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: EMCON inherit question

Post 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
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: EMCON inherit question

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

Return to “Lua Legion”