Module:NzIcewayInline: Difference between revisions

From EarthMC
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 12: Line 12:
if lineCode:sub(1, 2) == "Hi" then
if lineCode:sub(1, 2) == "Hi" then
lineCode = lineCode:sub(3)
lineCode = lineCode:sub(3)
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|sub|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
elseif isInteger(lineCode) then
elseif isInteger(lineCode) then
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|sub|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
end
end
     return frame:preprocess("[[File:"..lineCode.." shield.png|25px|border]]")
     return frame:preprocess("[[File:"..lineCode.." shield.png|25px|sub|border]]")
end
end


return p
return p

Revision as of 21:30, 23 August 2026

Documentation for this module may be created at Module:NzIcewayInline/doc

local p = {} --p stands for package

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)
		return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|sub|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
	elseif isInteger(lineCode) then
		return frame:preprocess("[[File:New Zealand Highway "..lineCode..".png|25px|sub|border|link=Nostra:Highway "..lineCode.." (New Zealand)]]")
	end
    return frame:preprocess("[[File:"..lineCode.." shield.png|25px|sub|border]]")
end

return p