KnightHawk75
Posts: 1450
Joined: 11/15/2018 Status: offline
|
Chaff\flares etc are almost always on mounts, so you'll be making changes to mounts on the aircraft, and you'll need to grab the mount guids for each aircraft to do that, in addition to yes of course the guids to get the aircraft in the first place. To that end, to grab guids of units at any given base you can enumerate them via the .embaredUnits.Aircraft|Boats table of the host where they reside, this will pull the units that are present, .assignedUnits will pull all those assigned but not necessarily present. That could be a ship\S-U-A, it could be a singular piece\member of the airbase group, or commonly the AirBase group itself which sounds like your case. --local retval, mybase = pcall(SE_GetUnit,{guid="GroupsGuidHereIfYouHaveIt"}); --Get the group itself.
--or
local retval,mybase = pcall(SE_GetUnit,{side="Blue",name="SomeAirbaseGroupName"}); -- Get the group itself.
--Dump hosted Aircraft.
if ((retval ==true and mybase ~=nil) and mybase.embarkedUnits ~=nil) and #mybase.embarkedUnits.Aircraft > 0 then
print("There are " .. tostring(#mybase.embarkedUnits.Aircraft) .. " aircraft embarked on this unit. They are as follows:")
for i=1,#mybase.embarkedUnits.Aircraft do
--if you use a foreach (for k,v in pairs()...) here there are actually 4 entries because the entries are duplicated,
--one set for numeric keys and then one for string keys for the numeric number. So be careful if deciding to do that.
--ie mybase.embarkedUnits.Aircraft[1] and mybase.embarkedUnits.Aircraft['1'] are both valid but seperate entries.
print(string.format("[%s] guid: %s",tostring(i),tostring(mybase.embarkedUnits.Aircraft[i])));
--local u = SE_GetUnit({guid=mybase.embarkedUnits.Aircraft[i]});
--if u.something == something and u.somethingelse == somethingelse ... then
--call routine to dowhat you want.like lookup it's mounts, find the right one, and mod it, whole other topic.
--end
end
else
print("Could not obtain the unit or group, or there were no embrakedUnits.");
end
< Message edited by KnightHawk75 -- 7/10/2021 5:19:14 AM >
|