Module:AUshield
ښکارېدونکې بڼه
لاسوند لپاره ددې موډيول کېدای سی په Module:AUshield/لاسوند کي وي
local p = {}
function p.Shield(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
--store special inputs
local customsize = args["size"] -- store custom size if specified
local alt = args["alt"] or "" -- store value of alt
args["alt"], args["size"] = nil, nil -- destroy before populating tables
-- populate table of highway types
local htype = {}
local indexcount = 1
for i = 1,7,2 do -- set to grab 4
if args[i] then
htype[indexcount] = args[i] -- Get types of highway
indexcount = indexcount + 1
end
end
-- populate table of allocations (route numbers)
local alloc = {}
indexcount = 1
for i = 2,8,2 do -- set to grab 4
if args[i] then
alloc[indexcount] = args[i] -- Get allocations (route numbers)
indexcount = indexcount + 1
end
end
-- set up extension (currently not required)
local ext = ".svg" -- this shouldnt need to ever change, but its here if needed. (it could also be moved into the table below)
-- set up base types of highways with properties
local entries = {N = { filename = "File:AUS national highway ", description = "National Highway ", size = "x20px"},
ACTN={ filename = "File:AUS national highway variation ", description = "National Highway ", size = "x20px"},
AN = { filename = "File:Australian Alphanumeric Route ", description = "State Route ", size = "x15px"},
NSW= { filename = "File:NSW alphanumeric route ", description = "Route ", size = "x20px"},
S = { filename = "File:AUS state route ", description = "State Route ", size = "x20px"},
R = { filename = "File:AUS national route ", description = "National Route ", size = "x20px"},
T = { filename = "File:Australian Tourist Route ", description = "Tourist Drive ", size = "x20px"},
ACTT={ filename = "File:ACT Tourist Drive ", description = "Tourist Drive ", size = "x20px"},
Met= { filename = "File:Metroad ", description = "Metroad ", size = "x20px"},
Syd= { filename = "File:Former Sydney route ", description = "Freeway ", size = "x20px"},
SydRR={ filename = "File:Former Sydney ring road ", description = "Sydney Ring Road ", size = "x20px"},
MelRR={ filename = "File:Former Melbourne Ring Road ", description = "Melbourne Ring Road ", size = "x20px"}};
-- set up base type aliases (used if highway types share all properites)
local aliases = {QLD = "AN", SA = "AN", NT = "AN", VIC = "AN", TAS = "AN", -- State specific aliases for AN
ACT = "NSW"}; -- ACT uses NSW properties
setmetatable(entries, {__index = function(t,k) return rawget(t,aliases[k]); end});
--produce shields
local count = 1
local shield = {}
repeat
if alt == "on" then
table.insert(shield, "[[" .. entries[(htype[count])].filename .. alloc[count] .. ext .. "|" .. (customsize or entries[(htype[count])].size) .. "|alt=" .. entries[(htype[count])].description .. alloc[count] .. "]]" or nil)
else
table.insert(shield, "[[" .. entries[(htype[count])].filename .. alloc[count] .. ext .. "|" .. (customsize or entries[(htype[count])].size) .. "|link=|alt=]]" or nil)
end
count = count + 1
until count == indexcount -- compare count to number of shields grabbed earlier
return (shield[1] or "") .. (shield[2] or "") .. (shield[3] or "") .. (shield[4] or "")
end
return p