johnv2pt0 Posted May 11, 2020 Posted May 11, 2020 getAmmo() doesn't unless I'm doing something wrong. getSensors() references vehicle capabilities as far as I can tell. Is there any way to detect if an aircraft has one loaded?
Catweedle Posted May 12, 2020 Posted May 12, 2020 Iterate over a unit's table and its pylons. This is how the unit/-s table for a group looks like (found in the mission file inside .miz archives): ["units"] = { [1] = { ["alt"] = 2000, ["hardpoint_racks"] = true, ["alt_type"] = "BARO", ["livery_id"] = "VFA-37", ["skill"] = "High", ["speed"] = 179.86111111111, ["AddPropAircraft"] = { }, -- end of ["AddPropAircraft"] ["type"] = "FA-18C_hornet", ["unitId"] = 1, ["psi"] = 0, ["y"] = 632571.42857143, ["x"] = -298571.42857143, ["name"] = "DictKey_UnitName_7", ["payload"] = { ["[b]pylons[/b]"] = { [1] = { ["CLSID"] = "{5CE2FF2A-645A-4197-B48D-8720AC69394F}", }, -- end of [1] [2] = { ["CLSID"] = "{C40A1E3A-DD05-40D9-85A4-217729E37FAE}", }, -- end of [2] [3] = { ["CLSID"] = "{GBU-38}", }, -- end of [3] [4] = { ["CLSID"] = "{AAQ-28_LEFT}", }, -- end of [4] [5] = { ["CLSID"] = "{AWW-13}", }, -- end of [5] [7] = { ["CLSID"] = "{DB769D48-67D7-42ED-A2BE-108D566C8B1E}", }, -- end of [7] [8] = { ["CLSID"] = "{9BCC2A2B-5708-4860-B1F1-053A18442067}", }, -- end of [8] [9] = { ["CLSID"] = "{5CE2FF2A-645A-4197-B48D-8720AC69394F}", }, -- end of [9] }, -- end of ["pylons"] ["fuel"] = 4900, ["flare"] = 30, ["ammo_type"] = 1, ["chaff"] = 60, ["gun"] = 100, }, -- end of ["payload"] ["heading"] = 0, ["callsign"] = { [1] = 1, [2] = 1, [3] = 1, ["name"] = "Enfield11", }, -- end of ["callsign"] ["onboard_num"] = "010", }, -- end of [1] }, -- end of ["units"] Example for iterating over pylons: function print_payloads() for coa_name, coa_data in pairs(env.mission.coalition) do if (coa_name == 'red' or coa_name == 'blue') and type(coa_data) == 'table' then if coa_data.country then for cntry_id, cntry_data in pairs(coa_data.country) do for obj_type_name, obj_type_data in pairs(cntry_data) do if obj_type_name == "helicopter" or obj_type_name == "plane" then if ((type(obj_type_data) == 'table') and obj_type_data.group and (type(obj_type_data.group) == 'table') and (#obj_type_data.group > 0)) then for group_num, group_data in pairs(obj_type_data.group) do local groupName = env.getValueDictByKey(group_data.name) if group_data then for unitIndex, unitData in pairs(group_data.units) do local unitName = env.getValueDictByKey(unitData.name) env.info("Pylons for unit "..unitName.." ("..unitData.type.."/"..groupName.."):") local pylons = [b]unitData.payload.pylons[/b] for k,v in pairs(pylons) do env.info(k.."> "..v.[b][color="DarkRed"]CLSID[/color][/b]) end end end end end end end end end end end return end This will print something like this -- the ordnance/pods/.. are represented as CLSID: Pylons for unit Pilot #001 (FA-18C_hornet/TestHornet): 9> {5CE2FF2A-645A-4197-B48D-8720AC69394F} 2> {C40A1E3A-DD05-40D9-85A4-217729E37FAE} 8> {9BCC2A2B-5708-4860-B1F1-053A18442067} 3> {GBU-38} 1> {5CE2FF2A-645A-4197-B48D-8720AC69394F} 4> {AAQ-28_LEFT} 5> {AWW-13} 7> {DB769D48-67D7-42ED-A2BE-108D566C8B1E} Of course you need to know the CLSID for pods or whatever you want to check. Either find them yourself in mission files or somewhere else.
Hardcard Posted May 13, 2020 Posted May 13, 2020 @Catweedle Thanks for sharing! :thumbup: [sIGPIC][/sIGPIC]
Recommended Posts