Module:Sandbox/BrandonXLF/3

This is an old revision of this page, as edited by BrandonXLF (talk | contribs) at 04:48, 8 September 2021. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

-- Sandbox, do not delete

local p = {}
local parser = require('Module:Road data/parser').parser

function p.subpages()
	local subpages = {
		'AFR',
		'ALB',
		'AND',
		'ARE',
		'ARG',
		'ARM',
		'ASIA',
		'AUS',
		'AUT',
		'AZE',
		'BEL',
		'BEN',
		'BGD',
		'BGR',
		'BIH',
		'BLR',
		'BLZ',
		'BOL',
		'BRA',
		'CAN',
		'CAN/AB',
		'CAN/BC',
		'CAN/MB',
		'CAN/NB',
		'CAN/NL',
		'CAN/NS',
		'CAN/NT',
		'CAN/ON',
		'CAN/PE',
		'CAN/QC',
		'CAN/SK',
		'CAN/YT',
		'CHE',
		'CHL',
		'CHN',
		'COL',
		'CRI',
		'CYP',
		'CZE',
		'DEU',
		'DJI',
		'DNK',
		'DZA',
		'ECU',
		'ESP',
		'EST',
		'EUR',
		'FIN',
		'FRA',
		'GBR',
		'GEO',
		'GHA',
		'GIB',
		'GRC',
		'HKG',
		'HRV',
		'HUN',
		'IDN',
		'IMN',
		'IND',
		'IRL',
		'IRN',
		'IRQ',
		'ISL',
		'ISR',
		'ITA',
		'JAM',
		'JOR',
		'JPN',
		'KAM',
		'KAZ',
		'KGZ',
		'KOR',
		'KOS',
		'LAO',
		'LKA',
		'LSO',
		'LTU',
		'LUX',
		'LVA',
		'MDA',
		'MEX',
		'MKD',
		'MMR',
		'MNE',
		'MTQ',
		'MYS',
		'NAM',
		'NIC',
		'NIR',
		'NLD',
		'NOR',
		'NPL',
		'NZL',
		'OMN',
		'PAK',
		'PER',
		'PHL',
		'PK',
		'POL',
		'PRT',
		'ROU',
		'RUS',
		'SAD',
		'SRB',
		'SVK',
		'SVN',
		'SWE',
		'THA',
		'TUR',
		'TWN',
		'UKR',
		'URY',
		'USA',
		'USA/AK',
		'USA/AL',
		'USA/AR',
		'USA/AS',
		'USA/AZ',
		'USA/CA',
		'USA/CO',
		'USA/CT',
		'USA/DC',
		'USA/DE',
		'USA/FL',
		'USA/GA',
		'USA/GU',
		'USA/HI',
		'USA/IA',
		'USA/ID',
		'USA/IL',
		-- 'USA/IN',
		'USA/KS',
		'USA/KY',
		'USA/LA',
		'USA/MA',
		'USA/MD',
		'USA/ME',
		'USA/MI',
		'USA/MN',
		'USA/MO',
		'USA/MP',
		'USA/MS',
		'USA/MT',
		'USA/NC',
		'USA/ND',
		'USA/NE',
		'USA/NH',
		'USA/NJ',
		'USA/NM',
		'USA/NV',
		'USA/NY',
		'USA/OH',
		'USA/OK',
		'USA/OR',
		'USA/PA',
		'USA/PR',
		'USA/RI',
		'USA/SC',
		'USA/SD',
		'USA/TN',
		'USA/TX',
		'USA/UT',
		'USA/VA',
		'USA/VI',
		'USA/VT',
		'USA/WA',
		'USA/WI',
		'USA/WV',
		'USA/WY',
		'UZB',
		'VEN',
		'VNM',
		'ZAF'
	}
	local out = ''
	
	for _, subpage in ipairs(subpages) do
		local data = require('Module:Road data/strings/' .. subpage)
		
		if type(data) == 'table' then
			for roadType, info in pairs(data) do
				local localOut = ''
				
				local shield = parser({
					['route'] = '1',
					['state'] = subpage:gsub('.+/', '')
				}, 'shield', roadType, 'Module:Road data/strings/' .. subpage)
			
				if type(shield) == 'table' then
					shield = shield[0]
				end
				
				if shield then
					localOut = localOut .. ('[[File:%s|x25px|alt=|link=]]'):format(shield)
				end
			
				local shieldmain = parser({
					['route'] = '1',
					['state'] = subpage:gsub('.+/', '')
				}, 'shieldmain', roadType, 'Module:Road data/strings/' .. subpage)	
			
				if type(shieldmain) == 'table' then
					shieldmain = shieldmain[0]
				end

				if shieldmain then
					localOut = localOut .. ('[[File:%s|x25px|alt=|link=]]'):format(shieldmain)
				end
				
				if localOut ~= '' then
					out = out .. '<br>' .. localOut .. ' ' .. subpage .. ' ' .. roadType
				end
			end
		end
	end
	
	return out
end

return p