Page 1 of 1
LUA OutOfComms
Posted: Mon Oct 22, 2018 4:21 pm
by De Savage
I want to simulate COM JAMMER and create area (four RP points) where enemy side will have nocomms and when they exit the area comms are back.
First I created event for unit entering, but cant figure out how to check UnitX and make it out of comms. And also I can't figure out how to get comms back after leaving area. Have anyone made this kind of LUA?
My example:
local unit = ScenEdit_UnitX()
ScenEdit_SetUnit({Side=”Japan”, unitname=UnitxX(), methodOutOfComms=”True”})
RE: LUA OutOfComms
Posted: Tue Oct 23, 2018 5:32 am
by michaelm75au
I don't think I have a function to change the OOC as it is relies on several factors. The unit wrapper only shows the state of it.
Someone else asked about this the other week, and I was going to see what is involved.
RE: LUA OutOfComms
Posted: Tue Oct 23, 2018 9:31 am
by michaelm75au
I have been reviewing the code, and you should be able to turn OUTOFCOMMS on and off.
local unit = ScenEdit_UnitX()
ScenEdit_SetUnit( {side = unit.side, unitname = unit.name, outofcomms = true} )
RE: LUA OutOfComms
Posted: Sun Mar 28, 2021 10:35 am
by Parel803
Good afternoon,
Hope someone can point me in the right direction and telling me what I'm doing wrong:
local Unit = ScenEdit_GetUnit({name='Protector USV [Typhoon, Armed] #1', guid='50PVO4-0HM7FN02G2FE9'})
-- out of comms
ScenEdit_SetUnit({side = Unit.side, guid=Unit.guid, outOfComms = true})
print (Unit.outOfComms)
probably something like a typo but not seeing it
with regards Gert-Jan
RE: LUA OutOfComms
Posted: Sun Mar 28, 2021 3:24 pm
by musurca
Here's the function I use internally, taking a Unit wrapper unit and a boolean commsState:
function Unit_SetOutOfComms(unit, commsState)
ScenEdit_SetUnit({guid=unit.guid, outOfComms=commsState})
end
Just tested it on 1147.18, and seemed to work okay. Your code looks close and I don't immediately see why the code you posted above wouldn't work. However I would note that you don't need to provide a side if you're also providing the GUID to _SetUnit (the GUID is unique among all units regardless of side). Possibly that's the issue?
RE: LUA OutOfComms
Posted: Mon Mar 29, 2021 4:47 pm
by Parel803
Thank you for your time and answer,
with regards Gert-Jan