Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Delete An Entire Group Of Units

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Delete An Entire Group Of Units Page: [1]
Login
Message << Older Topic   Newer Topic >>
Delete An Entire Group Of Units - 10/30/2019 7:52:35 AM   
butch4343

 

Posts: 302
Joined: 3/26/2015
Status: offline
Im looking for some help, I have a scenario am creating from an old Harpoon Gold Scenario.

In Harpoon airfields were single attackable units and in command they are not, I have worked out a way to destroy the whole base using LUA that is, have a single unit airfield called in this case wethersfield then create 20 hangars W1-12 group the lot together.

I then use a points based trigger to remove the airfield, and create the following script:

ScenEdit_DeleteUnit({side="NATO", unitname="Wethersfield1"})
ScenEdit_DeleteUnit({side="NATO", unitname="W1"})
ScenEdit_DeleteUnit({side="NATO", unitname="W2"})
ScenEdit_DeleteUnit({side="NATO", unitname="W3"})
ScenEdit_DeleteUnit({side="NATO", unitname="W4"})
ScenEdit_DeleteUnit({side="NATO", unitname="W5"})
ScenEdit_DeleteUnit({side="NATO", unitname="W6"})
ScenEdit_DeleteUnit({side="NATO", unitname="W7"})
ScenEdit_DeleteUnit({side="NATO", unitname="W8"})
ScenEdit_DeleteUnit({side="NATO", unitname="W9"})
ScenEdit_DeleteUnit({side="NATO", unitname="W10"})
ScenEdit_DeleteUnit({side="NATO", unitname="W11"})
ScenEdit_DeleteUnit({side="NATO", unitname="W12"})


Wethersfield1 is the single airfield unit in this case

This works really well, however its time consuming so I tried a second script to see if I could achieve the same effect on 1 line of code :

ScenEdit_DeleteUnit({side="NATO"name='Wethersfield'})

This code works but it deletes the group and leaves in place the units that made up the group which isnt exactly what I wanted to achieve. So is there a reasonably easy script I could use that will delete a Group AND its sub units in one go?

It would be much easier if Single Unit airfields were attackable lol
Kind Regards

Butch
Post #: 1
RE: Delete An Entire Group Of Units - 10/30/2019 12:15:20 PM   
SeaQueen


Posts: 1266
Joined: 4/14/2007
From: Washington D.C.
Status: offline
quote:

It would be much easier if Single Unit airfields were attackable lol


Then you'd have to listen to me whine about how your scenario totally sucks because I don't get to weaponeer each and every DMPI for every single JDAM coming off my B-2.

(in reply to butch4343)
Post #: 2
RE: Delete An Entire Group Of Units - 10/31/2019 1:47:59 AM   
Whicker

 

Posts: 662
Joined: 6/20/2018
Status: offline
you can get the unitlist from the group and then go over it to delete each unit, then delete the group.

quote:


local u = ScenEdit_GetUnit({name='groupName'})
unitsToChange = u.group.unitlist
for i = 1, #unitsToChange
do
--delete the unit here - unit list is list of guids I think (guid=unitsToChange)
end --loop

--delete the group here? not sure if there would be a group left if there were no units so maybe not


< Message edited by Whicker -- 10/31/2019 1:49:40 AM >

(in reply to SeaQueen)
Post #: 3
RE: Delete An Entire Group Of Units - 10/31/2019 8:50:35 AM   
michaelm75au


Posts: 13086
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
You should be able to delete the group with the units.
ScenEdit_DeleteUnit({side="NATO", unitname="Wethersfield1"}, true)

The binary option allows you to delete the 'group' and the attached units. By default, deleting a 'group' will only remove the 'group' unit = un-group it.

The Editor method drop-down list shows this extra option, but not the documentation.

< Message edited by michaelm75au -- 10/31/2019 8:54:31 AM >


_____________________________

Michael

(in reply to Whicker)
Post #: 4
RE: Delete An Entire Group Of Units - 11/6/2019 5:58:38 AM   
butch4343

 

Posts: 302
Joined: 3/26/2015
Status: offline
All,

Thanks for the really helpful replies, Ive just tried out the LUA codes and it works really well.

Thanks Again

Butch

(in reply to michaelm75au)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Delete An Entire Group Of Units Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.141