Jump to content

How do you cross-reference an airbase 'object' with the data for an airfield in 'radio.lua'?


Recommended Posts

Posted (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 by Elphaba
Posted (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 by Chump
  • Thanks 1
Posted
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.

 

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...