Create Group

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

Create Group

Post by TitaniumTrout »

I'm using ScenEdit_AddUnit to place several naval units. I want them all in the same group.
local NG = "TF20"
local cvn = ScenEdit_AddUnit({type ='Ship', name ='CVN-71 Theodore Roosevelt', heading =0, dbid =2587, side ='Player', Latitude=37.994,Longitude=-157.0, autodetectable="false",proficiency=3, group= NG})
cvn.group=NG
local cg = ScenEdit_AddUnit({type ='Ship', name ='CG1', heading =0, dbid =2859, side ='Player', Latitude=37.984,Longitude=-157.01, autodetectable="false",proficiency=3, group= NG})
local cg1 = ScenEdit_AddUnit({type ='Ship', name ='CG2', heading =0, dbid =2859, side ='Player', Latitude=37.974,Longitude=-157.02 , autodetectable="false",proficiency=3, group= NG})

If I define them all using the group = NG inside of the AddUnit function the units are placed, but are not in a group.

However if I define cvn.group=NG then the group is created and the next units are both added to the proper group without the additional call.

Is there a way to create the group inside of the function, or is cvn.group the best way to do it?
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Create Group

Post by KnightHawk75 »

Nope as of 1147.30 AddUnit() can not be used to create a group that did not exist before the call began.

Group='xyz' will always be processed, but ignored when a existing match is not found, it will not create a group for you. unitwrapper.group = 'xyz'; However will always assign the group, and create the group if it does not yet exist, and is the only way to initially create the group.

Personally I tend to just add unit.group=var after each add in a package\group set, such that should something above it fail but execution continue due to error trapping and handling then the rest of the package that does succeed gets it's proper group assignments. Entirely up to you.
Post Reply

Return to “Lua Legion”