LUA OutOfComms

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
De Savage
Posts: 79
Joined: Mon Jun 16, 2014 12:25 pm

LUA OutOfComms

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

User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA OutOfComms

Post 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.
Michael
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA OutOfComms

Post 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} )
Michael
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: LUA OutOfComms

Post 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
musurca
Posts: 168
Joined: Wed Jul 15, 2020 10:06 pm
Contact:

RE: LUA OutOfComms

Post 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?
Parel803
Posts: 962
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

RE: LUA OutOfComms

Post by Parel803 »

Thank you for your time and answer,
with regards Gert-Jan
Post Reply

Return to “Lua Legion”