Page 1 of 1

Create Group

Posted: Thu Oct 07, 2021 11:09 am
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?

RE: Create Group

Posted: Fri Oct 08, 2021 12:31 am
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.