Module:NzIcewayInline: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} --p stands for package | local p = {} --p stands for package | ||
local linePages = { | |||
ACL = "Auckland Circle line", | |||
BZL = "Blazerwood line", | |||
BoP = "Bay of Plenty line", | |||
NL = "Napier line", | |||
NZML = "North–South Main line (New Zealand)", | |||
SPL = "South Pacific link", | |||
TTL = "Trans-Tasman link", | |||
WB = "World Border line" | |||
} | |||
local fileModule = require("Module:FileExists") | local fileModule = require("Module:FileExists") | ||
| Line 12: | Line 23: | ||
if lineCode:sub(1, 2) == "Hi" then | if lineCode:sub(1, 2) == "Hi" then | ||
lineCode = lineCode:sub(3) | lineCode = lineCode:sub(3) | ||
end | end | ||
return frame:preprocess("[[File:"..lineCode.." shield.png|30px| | if isInteger(lineCode) then | ||
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|30px|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]") | |||
end | |||
return frame:preprocess("[[File:"..lineCode.." shield.png|30px|border|link=Nostra:"..linePages[lineCode].."]]") | |||
end | end | ||
return p | return p | ||
Latest revision as of 21:46, 23 August 2026
Documentation for this module may be created at Module:NzIcewayInline/doc
local p = {} --p stands for package
local linePages = {
ACL = "Auckland Circle line",
BZL = "Blazerwood line",
BoP = "Bay of Plenty line",
NL = "Napier line",
NZML = "North–South Main line (New Zealand)",
SPL = "South Pacific link",
TTL = "Trans-Tasman link",
WB = "World Border line"
}
local fileModule = require("Module:FileExists")
local function isInteger(str)
return str:match("^[+-]?%d+$") ~= nil
end
--1: IGN 2: TYPE 3: VARIANT 4: SIZE
function p.template( frame )
local lineCode = frame.args[1]
if lineCode:sub(1, 2) == "Hi" then
lineCode = lineCode:sub(3)
end
if isInteger(lineCode) then
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|30px|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
end
return frame:preprocess("[[File:"..lineCode.." shield.png|30px|border|link=Nostra:"..linePages[lineCode].."]]")
end
return p