Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Lua Question: Units Detach/Join Group

 
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 Question: Units Detach/Join Group Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua Question: Units Detach/Join Group - 7/14/2017 10:22:25 AM   
AlGrant


Posts: 912
Joined: 8/18/2015
Status: offline

Is there a way in Lua to detach units from a group and assign them to a new group ?

In an AI controlled side I have a group with a carrier and a number of escorts, at some point I want to detach 3 of the escorts from the carrier Group and assign them to a new Group and then to a new mission.

I have managed to get the actions I want by having the carrier group composed of 2 smaller groups, one with the escorts made relative to the carrier and then simply assign to a new mission .... it works and gets the results I'm looking for but but is a bit messy, so wondering if I can tidy things up a bit with Lua.

I've no problems with checking the units are still active and assigning to a new mission, but can't seem to split them up if all part of the same group.

Cheers
Al



_____________________________

GOD'S EYE DISABLED.
Post #: 1
RE: Lua Question: Units Detach/Join Group - 7/14/2017 1:09:28 PM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
local unit=ScenEdit_GetUnit({name='USS Rentz', guid='ee495732-1637-463a-b6c9-e2564150c8bf'})
unit.group='new group'
print(unit)

_____________________________

Michael

(in reply to AlGrant)
Post #: 2
RE: Lua Question: Units Detach/Join Group - 7/14/2017 1:26:04 PM   
AlGrant


Posts: 912
Joined: 8/18/2015
Status: offline

Thanks Michael, Much appreciated. I'll give that a run tonight.

Much easier and neater than my messy attempt.


_____________________________

GOD'S EYE DISABLED.

(in reply to michaelm75au)
Post #: 3
RE: Lua Question: Units Detach/Join Group - 7/14/2017 7:50:38 PM   
AlGrant


Posts: 912
Joined: 8/18/2015
Status: offline
Works perfectly...

I've now got an AI carrier TG conducting air attacks on another TG.
If the aircraft losses rise above a certain level (and they are likely to) then the carrier group will withdraw to safety whilst a SAG Group will detach to conduct a surf attack.
Far better than the carrier just sitting there as a big juicy target!

..... Thank again Michael



_____________________________

GOD'S EYE DISABLED.

(in reply to AlGrant)
Post #: 4
RE: Lua Question: Units Detach/Join Group - 7/14/2017 8:04:54 PM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
AlGrant

Would it be possible to get a copy of your script for that - sounds like something I can certainly use.

Thanks

B

(in reply to AlGrant)
Post #: 5
RE: Lua Question: Units Detach/Join Group - 7/15/2017 9:28:08 AM   
AlGrant


Posts: 912
Joined: 8/18/2015
Status: offline

I'll be away from my Command laptop until Sunday evening but can send you the script snippets once I get back.

I'll say straight off that I AM USELESS AT LUA so there's no Lua magic involed but with some help and tweaking a few existing scripts I have managed to get the AI side to do what I want! Amazingly some if it is actually starting to make sense

Basically I'm using a few Events and a Lua counter as found in Mikes example here: http://www.mikmyk.com/uncategorized/cmano-lua-key-values-counters-and-behaviors/ to count the destroyed aircraft and assign the CV group to a new mission area (for withdrawl) once a threshold is reached.

Then I've used michaelm's example above to switch out some of the escorts to a new group and send them to a new sea control mission to conduct a surface attack and cover the CV's retreat.

In the scenario I'm building the Argentine carrier only has a limited number of aircraft and losing a few leaves it a bit exposed.
So I'm getting here to withdraw to a safer area, I might try to reassign a few Argentine Navy A-4's from a shore base to get her back to fighting strength.

Al



_____________________________

GOD'S EYE DISABLED.

(in reply to Gunner98)
Post #: 6
RE: Lua Question: Units Detach/Join Group - 7/15/2017 9:39:42 AM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
Acknowledged. I consider myself a Lua numpty! So anything I find useful gets scrounged into a document for use when I need it, as opposed to working through the code myself - which I will admit, is getting easier.

Thanks

Bart

(in reply to AlGrant)
Post #: 7
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Question: Units Detach/Join Group 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

2.984