LUA to delete a group of units?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
hellfish6
Posts: 695
Joined: Sun Jun 15, 2008 2:09 am

LUA to delete a group of units?

Post by hellfish6 »

I'd like to be able to delete an airbase and its defenses, which are grouped together, when an amphibious assault force arrives in an area. Is it possible to do a LUA to delete the whole group, or do I have to delete each and every component?

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

RE: LUA to delete a group of units?

Post by michaelm75au »

You should be able. The default mode of ScenEdit_DeleteUnit() is to do one unit.
There is an option on the command to do all units in the group
ScenEdit_DeleteUnit( {table} , true) --- the 'true' should take all the units. [This should be in the current build as it was added during 1.13]
Michael
User avatar
hellfish6
Posts: 695
Joined: Sun Jun 15, 2008 2:09 am

RE: LUA to delete a group of units?

Post by hellfish6 »

So in the table to I need to list each component unit or just the name of the group?
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA to delete a group of units?

Post by michaelm75au »

To delete a group 'mygroup'
ScenEdit_DeleteUnit( {side='myside', name='mygroup'} , true)
Michael
User avatar
hellfish6
Posts: 695
Joined: Sun Jun 15, 2008 2:09 am

RE: LUA to delete a group of units?

Post by hellfish6 »

Awesome. Thank you very much.
AlphaSierra
Posts: 132
Joined: Mon Feb 13, 2017 9:35 am

RE: LUA to delete a group of units?

Post by AlphaSierra »

I have a Group that I use to teleport units to "randomize it's starting point.

Each unit in the Group has a mission.

I can manually delete/dissolve the group during play (by selecting the group then delete key) causing each unit to "steer" on it's mission.

How can I dissolve the group but maintain the units?

Thank you.



I wish to have no connection with any ship that does not sail fast; for I intend to go in harm's way. -John Paul Jones
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: LUA to delete a group of units?

Post by michaelm75au »

Just clear the group on the unit.
unit = SE_GetUnit(...)
unit.group =''
ORIGINAL: AlphaSierra

I have a Group that I use to teleport units to "randomize it's starting point.

Each unit in the Group has a mission.

I can manually delete/dissolve the group during play (by selecting the group then delete key) causing each unit to "steer" on it's mission.

How can I dissolve the group but maintain the units?

Thank you.



Michael
AlphaSierra
Posts: 132
Joined: Mon Feb 13, 2017 9:35 am

RE: LUA to delete a group of units?

Post by AlphaSierra »

Great Idea Thanks
I wish to have no connection with any ship that does not sail fast; for I intend to go in harm's way. -John Paul Jones
Post Reply

Return to “Lua Legion”