Jump to content

Module:Sandbox/BrandonXLF/4

From Wikipedia, the free encyclopedia
This is the current revision of this page, as edited by BrandonXLF (talk | contribs) at 06:44, 24 August 2024 (Fix errors). The present address (URL) is a permanent link to this version.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

-- Sandbox, do not delete
local p = {}

local roadDataModule = require('Module:Road data/sandbox') -- REMOVE SANDBOX

function p._shieldmain(args)
	local shields = {}
	local routeCount = 1
	
	while args[routeCount * 2 - 1] do
		local route = {
			country = args['country' .. routeCount] or args.country,
			state = args['state' .. routeCount] or args['province' .. routeCount] or args.state or args.province,
			type = args[routeCount * 2 - 1],
			route = args[routeCount * 2]
		}
		
		if not route.country then
			local countryModule = mw.loadData('Module:Road data/countrymask')
			route.country = countryModule[route.state] or 'UNK'
		end

		local shield = roadDataModule.shield(route, 'main', 'infobox', true)
		table.insert(shields, shield)

		routeCount = routeCount + 1
	end

	return table.concat(shields, ' ')
end

function p.shieldmain(frame)
	local args = require('Module:Arguments').getArgs(frame)
	return p._shieldmain(args)
end

return p