enumerate units (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


pclaurent -> enumerate units (7/22/2020 1:34:51 PM)

Simple question:
Is there a way to get a list of all existing units of a given side using a lua script?




KnightHawk75 -> RE: enumerate units (7/22/2020 8:00:50 PM)

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





pclaurent -> RE: enumerate units (7/22/2020 8:21:34 PM)

Wow, works great. Filtering by type should be a piece of cake. Thanks!




KnightHawk75 -> RE: enumerate units (7/22/2020 8:50:13 PM)

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





pclaurent -> RE: enumerate units (7/24/2020 8:08:36 AM)

got it - works fine. Tx




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.75