Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

enumerate 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 >> enumerate units Page: [1]
Login
Message << Older Topic   Newer Topic >>
enumerate units - 7/22/2020 1:34:51 PM   
pclaurent

 

Posts: 49
Joined: 5/17/2019
Status: offline
Simple question:
Is there a way to get a list of all existing units of a given side using a lua script?
Post #: 1
RE: enumerate units - 7/22/2020 8:00:50 PM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
If you want them not filtered by type at all...

local s = VP_GetSide({Side="myside"})
for k,v in pairs(s.units) do --units holds a table of all unit names and guids.
print('name: ' .. v.name .. ' guid: ' .. tostring(v.guid))
end



< Message edited by KnightHawk75 -- 7/22/2020 8:07:47 PM >

(in reply to pclaurent)
Post #: 2
RE: enumerate units - 7/22/2020 8:21:34 PM   
pclaurent

 

Posts: 49
Joined: 5/17/2019
Status: offline
Wow, works great. Filtering by type should be a piece of cake. Thanks!

(in reply to KnightHawk75)
Post #: 3
RE: enumerate units - 7/22/2020 8:50:13 PM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline
Keep in mind you don't have to do some of the filtering yourself anymore in 1146+
You can use enhancements to s:unitsBy() filtering mechanisms for type and then subtype or category with-in that type to get back a prefiltered table. Super handy and faster than old way of sub filtering manually.

ie
side:unitsBy('Ship')
side:unitsBy('Ship',2002)
side:unitsBy('Ship', 2002, 3003)
side:unitsBy('Ship',,3002)
etc



< Message edited by KnightHawk75 -- 7/22/2020 8:51:08 PM >

(in reply to pclaurent)
Post #: 4
RE: enumerate units - 7/24/2020 8:08:36 AM   
pclaurent

 

Posts: 49
Joined: 5/17/2019
Status: offline
got it - works fine. Tx

(in reply to KnightHawk75)
Post #: 5
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> enumerate 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.719