Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Nbound/Scribbles
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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"}, 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"}, Met= { filename = "File:Metroad ", description = "Metroad ", 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", -- all use alpha numeric ACT = "NSW"}; --ACT also uses NSW style alphanumeric 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
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Nbound/Scribbles/doc
(
edit
)