Query if unit is a helicopter?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Query if unit is a helicopter?

Post by KnightHawk75 »

I have script that just wants to see if say a US helicopter is within distance of some other unit.

All the related code to run threw the units and check distance is fine, except can't seem to find a good way to tell if something is generically a helicopter or tilt wing category of aircraft. The people being rescued are 'listening' for that sweet sound of a chopper closing in on them while they're on the run.

On the Side Wrapper there is unitsBy which I use constantly but it doesn't take helicopters it takes the core type Aircraft. Unit.subtype is very helpful usually, but in this case the sub-type(s) can apply to things other than helicopters or tilt-wing, and for example asw coded units can have troop or cargo loadouts that I want to include in the scan so I can't very reliably use subtype.

Is there no way to get the base category 2003? I noticed this is an issue with the detection triggers as well. I though of using QueryDB but last I checked aircraft had not been implemented yet. At present my solution is just check for all the different dbid's of the choppers and tilt-wings that said target side has in the scenario. Functional but very specific to the scenario and easy to forget to update as things change during development but it fits better then filtering on unit.subtype for this particular use case. Other ideas?

If I'm not missing something, I wonder if we can add category to the Unit wrapper (even if it's just in the fields) preferably as a number but the enum string works also, that would solve this in the future, and for those wanting to use detection triggers they could at least then use 'aircraft' and then farm out the rest to a lua script to do sub filtering for helo's or whatever it may be. It also solves this beyond just aircraft, I ran into similar with ships and facilities in the past.

I guess it's a bit more involved but maybe also add optional category to Side:unitsBy('type') so maybe it's Side:unitsBy('type',['categoryvalue']) since the game doing that filtering is more efficient then proxying it via lua for large sides. But that's more a wishlist list for marginal performance\QOL gain thing than a need.


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

RE: Query if unit is a helicopter?

Post by michaelm75au »

I'll look at adding 'category' to the unit wrappers. I noticed that 'contact' wrapper have the 'category' label, but not the unit wrapper itself.
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Query if unit is a helicopter?

Post by KnightHawk75 »

ORIGINAL: michaelm75au

I'll look at adding 'category' to the unit wrappers. I noticed that 'contact' wrapper have the 'category' label, but not the unit wrapper itself.

Thank you michaelm75au!

yeah, in this case I don't have a contact\detection yet.
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Query if unit is a helicopter?

Post by michaelm75au »

I have update the Command Lua page with the category codes for future use.

Image
Attachments
category.jpg
category.jpg (89.96 KiB) Viewed 471 times
Michael
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Query if unit is a helicopter?

Post by KnightHawk75 »

Thank you sir. Definitely will save some trips to the sqlbrowser. [:)]
jkgarner
Posts: 175
Joined: Thu Apr 30, 2020 12:42 pm

RE: Query if unit is a helicopter?

Post by jkgarner »

To which version of Command (PE) was the category added to the unit wrapper?
(The comments do not indicate)

I am attempting to do category checks against my mobile units in PE v 1.15.3, which came out last summer, but it seems that this capability does not exist in this version of the tool.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Query if unit is a helicopter?

Post by KnightHawk75 »

ORIGINAL: jkgarner

To which version of Command (PE) was the category added to the unit wrapper?
(The comments do not indicate)

I am attempting to do category checks against my mobile units in PE v 1.15.3, which came out last summer, but it seems that this capability does not exist in this version of the tool.

That's one for Michael when it comes to PE, game version got it last summer (I think in maybe 1147.7 but don't quote me on that).
User avatar
michaelm75au
Posts: 12465
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Query if unit is a helicopter?

Post by michaelm75au »

ORIGINAL: jkgarner

To which version of Command (PE) was the category added to the unit wrapper?
(The comments do not indicate)

I am attempting to do category checks against my mobile units in PE v 1.15.3, which came out last summer, but it seems that this capability does not exist in this version of the tool.

I don't have much visibility of the PE versions but I did manage to find a 1.15.* version of the Lua wrapper code which doesn't have 'category' in the unit wrapper.
Michael
Post Reply

Return to “Lua Legion”