विभाग:AUshield
वापर
संपादनहा विभाग इतर साच्यातून वापरताना खालील आज्ञा वापराव्यात.
{{#invoke:AUshield|Shield}}
Basic Module Description
संपादन- This module has a table of base highway types and their properties. Output is created by using the route type parameter to look up properties for that type of route, and then creating "
[[File:... ...]]
" using the route number as well, to ensure the appropriate file is linked. Provision is also made for alt text, and custom sizing. See comments within code for more specific information. - Note: The limitation of 4 shields can be increased if needed with minor modification, and has only been enforced to match the functionality of
{{AUshield}}
.
Template Data
संपादनThe template that is used to invoke this module requires the following parameters:
प्राचल | वर्णन | प्रकार | स्थिती | |
---|---|---|---|---|
1st route type | 1 | The code for the route type (see [[Template:AUshield]] for a description of the codes) | तंतू | हवे |
1st route number | 2 | The route number | तंतू | हवे |
2nd route type | 3 | The code for the route type (see [[Template:AUshield]] for a description of the codes) | तंतू | ऐच्छिक |
2nd route number | 4 | The route number | तंतू | ऐच्छिक |
3rd route type | 5 | The code for the route type (see [[Template:AUshield]] for a description of the codes) | तंतू | ऐच्छिक |
3rd route number | 6 | The route number | तंतू | ऐच्छिक |
4th route type | 7 | The code for the route type (see [[Template:AUshield]] for a description of the codes) | तंतू | ऐच्छिक |
4th route number | 8 | The route number | तंतू | ऐच्छिक |
Show alternate text and image link | alt | Normally this parameter should be left empty (Set this parameter to 'on' to include alt text, e.g. State Route 2, and the default image link), set '|alt=on' to activate | तंतू | ऐच्छिक |
image size | size | Normally this parameter should be left empty (Use this parameter to change image size. Allowed values are '<number>px', to set the width in pixels, or 'x<number>px', to set the height in pixels) | तंतू | ऐच्छिक |
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