TEMPEST.114 Posted February 11, 2023 Posted February 11, 2023 (edited) For the life of me I can't understand the obfuscation and 'logic' in these two designs. In the airbase.getDesc() we have: ['life'] = 3600, ['attributes'] = { ['Airfields'] = true }, ['_origin'] = '', ['category'] = 0, ['typeName'] = 'Anapa-Vityazevo', ['displayName'] = 'Anapa-Vityazevo' Yet in Radio.lua we have: { radioId = 'airfield12_0'; role = {"ground", "tower", "approach"}; callsign = {{["common"] = {_("Anapa"), "Anapa"}}}; frequency = {[HF] = {MODULATIONTYPE_AM, 3750000.000000}, [UHF] = {MODULATIONTYPE_AM, 250000000.000000}, [VHF_HI] = {MODULATIONTYPE_AM, 121000000.000000}, [VHF_LOW] = {MODULATIONTYPE_AM, 38400000.000000}}; sceneObjects = {'t:136022192'}; }; The name is different, there is no common 'id' between them... no idea what 't:136022192' is... so how does one marry the two up without having to manually type a table of key / value pairs linking them?! Is there some missing 'bridge' file and why is this 'architecture' so overly complicated? Edited February 11, 2023 by Elphaba
Chump Posted February 11, 2023 Posted February 11, 2023 (edited) @Elphaba I can think of a way to associate by airbase ID (it ain't pretty, just a suggestion): local radios = {} dofile(string.format("./Mods/terrains/%s/Radio.lua", env.mission.theatre)) if radio then for _, airbase in ipairs(coalition.getAirbases(coalition.side.BLUE)) do local radioId = string.format("airfield%d_", airbase:getID()) for _, r in ipairs(radio) do if string.find(r.radioId, radioId) then radios[airbase:getTypeName()] = r break end end end end -- now you have a table of associated radio entries by airbase -- ex: radios["Anapa-Vityazevo"].frequency.UHF[2] EDIT: I was originally thinking of Beacons.lua where there are multiple entries per airbase. Since here it is 1:1, it makes the loop easier. Edited February 11, 2023 by Chump 1
TEMPEST.114 Posted February 11, 2023 Author Posted February 11, 2023 14 minutes ago, Chump said: @Elphaba I can think of a way to associate by airbase ID (it ain't pretty, just a suggestion): dofile(string.format("./Mods/terrains/%s/Radio.lua", env.mission.theatre)) if radio then local allRadios = {} for _, airbase in ipairs(coalition.getAirbases(coalition.side.BLUE)) do local id = airbase:getID() local radioId = string.format("airfield%d_", id) local radios = {} for _, r in ipairs(radio) do if string.find(r.radioId, radioId) then table.insert(radios, r) end end allRadios[airbase:getTypeName()] = radios end -- now you have a table of associated radio entries by airbase -- ex: allRadios["Anapa-Vityazevo"][1].frequency.UHF[2] end Thanks for that. It's a huge help.
Chump Posted February 12, 2023 Posted February 12, 2023 @Elphaba Please see my edited post/code. Glad to help! 1
TEMPEST.114 Posted February 12, 2023 Author Posted February 12, 2023 Just now, Chump said: @Elphaba Please see my edited post/code. Glad to help! I have it all working now - thanks to you.
Recommended Posts