Difference between revisions of "Module:MediumLink"

From Nookipedia, the Animal Crossing wiki
(getting the SSB4 module set up)
m (Small grammar fix.)
 
(7 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
local p = {}
 
local p = {}
 
+
local getArgs = require('Module:Arguments').getArgs
local function getArgs(frame)
 
    local args = {}
 
    for key, value in pairs(frame:getParent().args) do
 
        args[key] = value
 
    end
 
    for key, value in pairs(frame.args) do
 
        args[key] = value
 
    end
 
    return args
 
end
 
  
 
function p.main(frame)
 
function p.main(frame)
Line 22: Line 12:
 
     local mode2      = args[2] or args.mode2 or ''
 
     local mode2      = args[2] or args.mode2 or ''
 
     local mode3      = args[3] or args.mode3 or ''
 
     local mode3      = args[3] or args.mode3 or ''
     local mode4      = args[4] or args.mode4 or ''
+
     return p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2, mode3)
    if medium == "Super Smash Bros. 4" then
 
    return p.outputSSB4Link(mode1, mode2, mode3, mode4)
 
    else
 
    return p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2, mode3)
 
    end
 
 
end
 
end
  
Line 35: Line 20:
 
end
 
end
 
local print = ''
 
local print = ''
local linkindicator = ''
+
local linkindicator = ""
 
if medium == "Gekijōban Doubutsu no Mori" then
 
if medium == "Gekijōban Doubutsu no Mori" then
 
linkindicator = "🎬 "
 
linkindicator = "🎬 "
 
end
 
end
local error = '\'\'\'<span class="error" dir="ltr" lang="en">Invalid parameters detected! Did you entered the wrong parameters or are the parameters needed to generate this link empty?</span>\'\'\'[[Category:Pages with incorrect usage of link template]]'
+
local error = '\'\'\'<span class="error" dir="ltr" lang="en">Invalid parameters detected! Did you enter the wrong parameters, or are the parameters needed to generate this link empty?</span>\'\'\'[[Category:Pages with incorrect usage of link template]]'
 
if not isEmpty(mode1) then
 
if not isEmpty(mode1) then
 
if mode1 == "nolink" then
 
if mode1 == "nolink" then
Line 96: Line 81:
 
print = "<small>''" .. short .. "''</small>"
 
print = "<small>''" .. short .. "''</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 +
elseif not isEmpty(linkindicator) then
 +
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>''[[" .. link .. "|" .. short .. "]]''</small>"
 
else
 
else
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
+
print = "<small>''[[" .. medium .. "|" .. short .. "]]''</small>"
 
end
 
end
 
else
 
else
Line 105: Line 94:
 
end
 
end
 
elseif isEmpty(mode2) then
 
elseif isEmpty(mode2) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]"
 
print = "[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]"
 +
elseif not isEmpty(linkindicator) then
 +
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]"
 +
elseif not isEmpty(link) then
 +
print = "''[[" .. link .. "|" .. short .. "]]''"
 
else
 
else
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]"
+
print = "''[[" .. medium .. "|" .. short .. "]]''"
 
end
 
end
 
else
 
else
Line 126: Line 119:
 
print = "<small>" .. shorter .. "</small>"
 
print = "<small>" .. shorter .. "</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 +
elseif not isEmpty(linkindicator) then
 +
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>[[" .. link .. "|" .. shorter .. "]]</small>"
 
else
 
else
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
+
print = "<small>[[" .. medium .. "|" .. shorter .. "]]</small>"
 
end
 
end
 
else
 
else
Line 135: Line 132:
 
end
 
end
 
elseif isEmpty(mode2) then
 
elseif isEmpty(mode2) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "[[" .. link .. "|" .. linkindicator .. shorter .. "]]"
 
print = "[[" .. link .. "|" .. linkindicator .. shorter .. "]]"
 +
elseif not isEmpty(linkindicator) then
 +
print = "[[" .. medium .. "|" .. linkindicator .. shorter .. "]]"
 +
elseif not isEmpty(link) then
 +
print = "[[" .. link .. "|" .. shorter .. "]]"
 
else
 
else
print = "[[" .. medium .. "|" .. linkindicator .. shorter .. "]]"
+
print = "[[" .. medium .. "|" .. shorter .. "]]"
 
end
 
end
 
else
 
else
Line 156: Line 157:
 
print = "<small>" .. shortest .. "</small>"
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
 +
elseif not isEmpty(linkindicator) then
 +
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>[[" .. link .. "|" .. shortest .. "]]</small>"
 
else
 
else
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
+
print = "<small>[[" .. medium .. "|" .. shortest .. "]]</small>"
 
end
 
end
 
else
 
else
Line 165: Line 170:
 
end
 
end
 
elseif isEmpty(mode2) then
 
elseif isEmpty(mode2) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "[[" .. link .. "|" .. linkindicator .. shortest .. "]]"
 
print = "[[" .. link .. "|" .. linkindicator .. shortest .. "]]"
 +
elseif not isEmpty(linkindicator) then
 +
print = "[[" .. medium .. "|" .. linkindicator .. shortest .. "]]"
 +
elseif not isEmpty(link) then
 +
print = "[[" .. link .. "|" .. shortest .. "]]"
 
else
 
else
print = "[[" .. medium .. "|" .. linkindicator .. shortest .. "]]"
+
print = "[[" .. medium .. "|" .. shortest .. "]]"
 
end
 
end
 
else
 
else
Line 190: Line 199:
 
print = "<small>''" .. short .. "''</small>"
 
print = "<small>''" .. short .. "''</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 +
elseif not isEmpty(linkindicator) then
 +
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>''[[" .. link .. "|" .. short .. "]]''</small>"
 
else
 
else
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
+
print = "<small>''[[" .. medium .. "|" .. short .. "]]''</small>"
 
end
 
end
 
else
 
else
Line 202: Line 215:
 
print = "<small>" .. shorter .. "</small>"
 
print = "<small>" .. shorter .. "</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 +
elseif not isEmpty(linkindicator) then
 +
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>[[" .. link .. "|" .. shorter .. "]]</small>"
 
else
 
else
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
+
print = "<small>[[" .. medium .. "|" .. shorter .. "]]</small>"
 
end
 
end
 
else
 
else
Line 214: Line 231:
 
print = "<small>" .. shortest .. "</small>"
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
elseif isEmpty(mode3) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
else
+
elseif not isEmpty(linkindicator) then
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
end
+
elseif not isEmpty(link) then
else
+
print = "<small>[[" .. link .. "|" .. shortest .. "]]</small>"
print = error
 
end
 
elseif isEmpty(mode2) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 
elseif not isEmpty(linkindicator) then
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 
else
 
print = "<small>''[[" .. medium .. "]]''</small>"
 
end
 
else
 
print = error
 
end
 
else
 
print = error
 
end
 
elseif isEmpty(mode1) then
 
if not isEmpty(link) then
 
print = "[[" .. link .. "|"  .. linkindicator .. "''" .. medium .. "'']]"
 
elseif not isEmpty(linkindicator) then
 
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]"
 
else
 
print = "''[[" .. medium .. "]]''"
 
end
 
else
 
print = error
 
end
 
return print
 
end
 
 
 
function p.outputSSB4Link(mode1, mode2, mode3, mode4)
 
local function isEmpty(s)
 
return s == nil or s == ''
 
end
 
local print = ''
 
local error = '\'\'\'<span class="error" dir="ltr" lang="en">Invalid parameters detected! Did you entered the wrong parameters?</span>\'\'\'[[Category:Pages with incorrect usage of link template]]'
 
if not isEmpty(mode1) then
 
if mode1 == "nolink" then
 
if not mode2 == "short" then
 
if mode3 == "sm" then
 
if mode4 == "3ds" then
 
print = "<small>''Smash 3DS''</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>''Smash Wii U''</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>''Smash 3DS / Wii U''</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>''Smash 4''</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "3ds" then
 
if mode4 == "sm" then
 
print = "<small>''Smash 3DS''</small>"
 
elseif isEmpty(mode4) then
 
print = "''Smash 3DS''"
 
else
 
print = error
 
end
 
elseif mode3 == "wiiu" then
 
if mode4 == "sm" then
 
print = "<small>''Smash Wii U''</small>"
 
elseif isEmpty(mode4) then
 
print = "''Smash Wii U''"
 
else
 
print = error
 
end
 
elseif mode3 == "3dswiiu" or mode4 == "wiiu3ds" then
 
if mode4 == "sm" then
 
print = "<small>''Smash 3DS / Wii U''</small>"
 
elseif isEmpty(mode4) then
 
print = "''Smash 3DS / Wii U''"
 
else
 
print = error
 
end
 
elseif isEmpty(mode3) then
 
print = "''Smash 4''"
 
else
 
print = error
 
end
 
elseif mode2 == "shorter" then
 
if mode3 == "sm" then
 
if mode4 == "3ds" then
 
print = "<small>SSB:3DS</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>SSB:Wii U</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>SSB4</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "3ds" then
 
if mode4 == "sm" then
 
print = "<small>SSB:3DS</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:3DS"
 
else
 
print = error
 
end
 
elseif mode3 == "wiiu" then
 
if mode4 == "sm" then
 
print = "<small>SSB:Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:Wii U"
 
else
 
print = error
 
end
 
elseif mode3 == "3dswiiu" or mode4 == "wiiu3ds" then
 
if mode4 == "sm" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:3DS/Wii U"
 
else
 
print = error
 
end
 
elseif isEmpty(mode3) then
 
print = "SSB4"
 
else
 
print = error
 
end
 
elseif mode2 == "shortest" then
 
if mode3 == "sm" then
 
if mode4 == "3ds" then
 
print = "<small>SSB:3DS</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>SSB:Wii U</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>SSB4</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "3ds" then
 
if mode4 == "sm" then
 
print = "<small>SSB:3DS</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:3DS"
 
else
 
print = error
 
end
 
elseif mode3 == "wiiu" then
 
if mode4 == "sm" then
 
print = "<small>SSB:Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:Wii U"
 
else
 
print = error
 
end
 
elseif mode3 == "3dswiiu" or mode4 == "wiiu3ds" then
 
if mode4 == "sm" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "SSB:3DS/Wii U"
 
else
 
print = error
 
end
 
elseif isEmpty(mode3) then
 
print = "SSB4"
 
else
 
print = error
 
end
 
elseif mode2 == "sm" then
 
if not mode3 == "short" then
 
if mode4 == "3ds" then
 
print = "<small>''Smash 3DS''</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>''Smash Wii U''</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>''Smash 3DS / Wii U'</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>''Smash 4''</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "shorter" then
 
if mode4 == "3ds" then
 
print = "<small>SSB:3DS</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>SSB:Wii U</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>SSB4</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "shortest" then
 
if mode4 == "3ds" then
 
print = "<small>SSB:3DS</small>"
 
elseif mode4 == "wiiu" then
 
print = "<small>SSB:Wii U</small>"
 
elseif mode4 == "3dswiiu" or mode4 == "wiiu3ds" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>SSB4</small>"
 
 
else
 
else
print = error
+
print = "<small>[[" .. medium .. "|" .. shortest .. "]]</small>"
end
 
elseif mode3 == "3ds" then
 
if mode4 == "short" then
 
print = "<small>''Smash 3DS''</small>"
 
elseif mode4 == "shorter" then
 
print = "<small>SSB:3DS</small>"
 
elseif mode4 == "shortest" then
 
print = "<small>SSB:3DS</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>''Super Smash Bros. for Nintendo 3DS''</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "wiiu" then
 
if mode4 == "short" then
 
print = "<small>''Smash Wii U''</small>"
 
elseif mode4 == "shorter" then
 
print = "<small>SSB:Wii U</small>"
 
elseif mode4 == "shortest" then
 
print = "<small>SSB:Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>''Super Smash Bros. for Wii U''</small>"
 
else
 
print = error
 
end
 
elseif mode3 == "3dswiiu" or mode3 == "wiiu3ds" then
 
if mode4 == "short" then
 
print = "<small>''Smash 3DS / Wii U''</small>"
 
elseif mode4 == "shorter" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif mode4 == "shortest" then
 
print = "<small>SSB:3DS/Wii U</small>"
 
elseif isEmpty(mode4) then
 
print = "<small>''Super Smash Bros. for Nintendo 3DS / Wii U''</small>"
 
else
 
print = error
 
end
 
elseif isEmpty(mode3) then
 
print = "<small>''Super Smash Bros. 4''</small>"
 
else
 
print = error
 
end
 
elseif isEmpty(mode2) then
 
print = "''Super Smash Bros. 4''"
 
else
 
print = error
 
end
 
elseif not isEmpty(short) and mode1 == "short" then
 
if mode2 == "nolink" then
 
if mode3 == "sm" then
 
print = "<small>''" .. short .. "''</small>"
 
elseif isEmpty(mode3) then
 
print = "''" .. short .. "''"
 
else
 
print = error
 
end
 
elseif mode2 == "sm" then
 
if mode3 == "nolink" then
 
print = "<small>''" .. short .. "''</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
end
 
else
 
print = error
 
end
 
elseif isEmpty(mode2) then
 
if not isEmpty(link) then
 
print = "[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]"
 
else
 
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]"
 
end
 
else
 
print = error
 
end
 
elseif not isEmpty(shorter) and mode1 == "shorter" then
 
if mode2 == "nolink" then
 
if mode3 == "sm" then
 
print = "<small>" .. shorter .. "</small>"
 
elseif isEmpty(mode3) then
 
print = shorter
 
else
 
print = error
 
end
 
elseif mode2 == "sm" then
 
if mode3 == "nolink" then
 
print = "<small>" .. shorter .. "</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
 
end
 
else
 
print = error
 
end
 
elseif isEmpty(mode2) then
 
if not isEmpty(link) then
 
print = "[[" .. link .. "|" .. linkindicator .. shorter .. "]]"
 
else
 
print = "[[" .. medium .. "|" .. linkindicator .. shorter .. "]]"
 
end
 
else
 
print = error
 
end
 
elseif not isEmpty(shortest) and mode1 == "shortest" then
 
if mode2 == "nolink" then
 
if mode3 == "sm" then
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
print = shortest
 
else
 
print = error
 
end
 
elseif mode2 == "sm" then
 
if mode3 == "nolink" then
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
 
end
 
else
 
print = error
 
end
 
elseif isEmpty(mode2) then
 
if not isEmpty(link) then
 
print = "[[" .. link .. "|" .. linkindicator .. shortest .. "]]"
 
else
 
print = "[[" .. medium .. "|" .. linkindicator .. shortest .. "]]"
 
end
 
else
 
print = error
 
end
 
elseif mode1 == "sm" then
 
if mode2 == "nolink" then
 
if not isEmpty(short) and mode3 == "short" then
 
print = "<small>''" .. short .. "''</small>"
 
elseif not isEmpty(shorter) and mode3 == "shorter" then
 
print = "<small>" .. shorter .. "</small>"
 
elseif not isEmpty(shortest) and mode3 == "shortest" then
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
print = "<small>''" .. medium .. "''</small>"
 
else
 
print = error
 
end
 
elseif not isEmpty(short) and mode2 == "short" then
 
if mode3 == "nolink" then
 
print = "<small>''" .. short .. "''</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
 
end
 
else
 
print = error
 
end
 
elseif not isEmpty(shorter) and mode2 == "shorter" then
 
if mode3 == "nolink" then
 
print = "<small>" .. shorter .. "</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
 
end
 
else
 
print = error
 
end
 
elseif not isEmpty(shortest) and mode2 == "shortest" then
 
if mode3 == "nolink" then
 
print = "<small>" .. shortest .. "</small>"
 
elseif isEmpty(mode3) then
 
if not isEmpty(link) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
 
else
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
 
 
end
 
end
 
else
 
else
Line 607: Line 244:
 
end
 
end
 
elseif isEmpty(mode2) then
 
elseif isEmpty(mode2) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 
print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 
elseif not isEmpty(linkindicator) then
 
elseif not isEmpty(linkindicator) then
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 
print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
 +
elseif not isEmpty(link) then
 +
print = "<small>''[[" .. link .. "|" .. medium .. "]]''</small>"
 
else
 
else
 
print = "<small>''[[" .. medium .. "]]''</small>"
 
print = "<small>''[[" .. medium .. "]]''</small>"
Line 621: Line 260:
 
end
 
end
 
elseif isEmpty(mode1) then
 
elseif isEmpty(mode1) then
if not isEmpty(link) then
+
if not isEmpty(link) and not isEmpty(linkindicator) then
 
print = "[[" .. link .. "|"  .. linkindicator .. "''" .. medium .. "'']]"
 
print = "[[" .. link .. "|"  .. linkindicator .. "''" .. medium .. "'']]"
 
elseif not isEmpty(linkindicator) then
 
elseif not isEmpty(linkindicator) then
 
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]"
 
print = "[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]"
 +
elseif not isEmpty(link) then
 +
print = "''[[" .. link .. "|" .. medium .. "]]''"
 
else
 
else
 
print = "''[[" .. medium .. "]]''"
 
print = "''[[" .. medium .. "]]''"

Latest revision as of 23:28, April 12, 2024

Module documentation (view)


Usage

This module is used to display the link of a medium in the Animal Crossing series in various different ways. These are then transcluded through link templates, where the editor can switch how they display the link under different conditions.

While it can be used inside other Lua modules if require("Module:MediumLink") is added, it is recommended to use through standard templates as is. Note that {{SSB4}} uses the Module:SSB4Link instead of this module.

Creating a new medium link

{{#invoke:MediumLink|main|medium=<medium>|link=<link (OPTIONAL)>|short=<short>|shorter=<shorter (OPTIONAL)>|shortest=<shortest (OPTIONAL)>|<mode1>|<mode2>|<mode3>}}
outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2, mode3)

When creating a new medium link to be used on pages, the following syntax is provided.

  • medium is the name of the medium (e.g. Animal Crossing: New Horizons)
  • link is used to provide the direct link to the medium.
  • short is the name of the medium under a shorthand name (e.g. New Horizons)
  • shorter is the name of the medium under a long acronym name (e.g. ACNH)
  • shortest is the name of the medium under a short acronym name (e.g. NH)
  • mode1, mode2, and mode3 should be reversed for the editors to decide what conditions to use to display the link.

If Gekijōban Doubutsu no Mori is declared as the medium, then linkindicator is automatically declared with "🎬 " and appended to the medium name if nolink is not declared.

Note that while shorter and shortest are optional, if they are not declared and the editor tries to declare shorter or shortest, an error will pop up, describing that they are either using invalid parameters or that the parameters needed to generate the link is empty. See Category:Pages with incorrect usage of link template for a list of pages with this error.

Example

{{#invoke:MediumLink|main|medium=Animal Crossing: New Horizons|short=New Horizons|shorter=ACNH|shortest=NH|{{{1|}}}|{{{2|}}}|{{{3|}}}}}
outputMediumLink("Animal Crossing: New Horizons", , "New Horizons", "ACNH", "NH", mode1, mode2, mode3)

"Animal Crossing: New Horizons" is the medium, with "New Horizons" as short, "ACNH" as shorter and "NH" as shortest. Since link is not declared, the default link is "Animal Crossing: New Horizons".

When mode1 is "nolink" and mode2 is "short", the output is: New Horizons

When mode1 is "sm" and mode2 is "shortest", the output is: NH

This page is fully-protected to prevent editing by non-administrator users

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.main(frame)
    local args        = getArgs(frame)
    local medium      = args.medium or ''
    local link        = args.link or ''
    local short       = args.short or ''
    local shorter     = args.shorter or ''
    local shortest    = args.shortest or ''
    local mode1       = args[1] or args.mode1 or ''
    local mode2       = args[2] or args.mode2 or ''
    local mode3       = args[3] or args.mode3 or ''
    return p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2, mode3)
end

function p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2, mode3)
	local function isEmpty(s)
		return s == nil or s == ''
	end
	local print = ''
	local linkindicator = ""
	if medium == "Gekijōban Doubutsu no Mori" then
		linkindicator = "🎬 "
	end
	local error = '\'\'\'<span class="error" dir="ltr" lang="en">Invalid parameters detected! Did you enter the wrong parameters, or are the parameters needed to generate this link empty?</span>\'\'\'[[Category:Pages with incorrect usage of link template]]'
	if not isEmpty(mode1) then
		if mode1 == "nolink" then
			if not isEmpty(short) and mode2 == "short" then
				if mode3 == "sm" then
					print = "<small>''" .. short .. "''</small>"
				elseif isEmpty(mode3) then
					print = "''" .. short .. "''"
				else
					print = error
				end
			elseif not isEmpty(shorter) and mode2 == "shorter" then
				if mode3 == "sm" then
					print = "<small>" .. shorter .. "</small>"
				elseif isEmpty(mode3) then
					print = shorter
				else
					print = error
				end
			elseif not isEmpty(shortest) and mode2 == "shortest" then
				if mode3 == "sm" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					print = shortest
				else
					print = error
				end
			elseif mode2 == "sm" then
				if not isEmpty(short) and mode3 == "short" then
					print = "<small>''" .. short .. "''</small>"
				elseif not isEmpty(shorter) and mode3 == "shorter" then
					print = "<small>" .. shorter .. "</small>"
				elseif not isEmpty(shortest) and mode3 == "shortest" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					print = "<small>''" .. medium .. "''</small>"
				else
					print = error
				end
			elseif isEmpty(mode2) then
				print = "''" .. medium .. "''"
			else
				print = error
			end
		elseif not isEmpty(short) and mode1 == "short" then
			if mode2 == "nolink" then
				if mode3 == "sm" then
					print = "<small>''" .. short .. "''</small>"
				elseif isEmpty(mode3) then
					print = "''" .. short .. "''"
				else
					print = error
				end
			elseif mode2 == "sm" then
				if mode3 == "nolink" then
					print = "<small>''" .. short .. "''</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
					elseif not isEmpty(link) then
						print = "<small>''[[" .. link .. "|" .. short .. "]]''</small>"
					else
						print = "<small>''[[" .. medium .. "|" .. short .. "]]''</small>"
					end
				else
					print = error
				end
			elseif isEmpty(mode2) then
				if not isEmpty(link) and not isEmpty(linkindicator) then
					print = "[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]"
				elseif not isEmpty(linkindicator) then
					print = "[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]"
				elseif not isEmpty(link) then
					print = "''[[" .. link .. "|" .. short .. "]]''"
				else
					print = "''[[" .. medium .. "|" .. short .. "]]''"
				end
			else
				print = error
			end
		elseif not isEmpty(shorter) and mode1 == "shorter" then
			if mode2 == "nolink" then
				if mode3 == "sm" then
					print = "<small>" .. shorter .. "</small>"
				elseif isEmpty(mode3) then
					print = shorter
				else
					print = error
				end
			elseif mode2 == "sm" then
				if mode3 == "nolink" then
					print = "<small>" .. shorter .. "</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
					elseif not isEmpty(link) then
						print = "<small>[[" .. link .. "|" .. shorter .. "]]</small>"
					else
						print = "<small>[[" .. medium .. "|" .. shorter .. "]]</small>"
					end
				else
					print = error
				end
			elseif isEmpty(mode2) then
				if not isEmpty(link) and not isEmpty(linkindicator) then
					print = "[[" .. link .. "|" .. linkindicator .. shorter .. "]]"
				elseif not isEmpty(linkindicator) then
					print = "[[" .. medium .. "|" .. linkindicator .. shorter .. "]]"
				elseif not isEmpty(link) then
					print = "[[" .. link .. "|" .. shorter .. "]]"
				else
					print = "[[" .. medium .. "|" .. shorter .. "]]"
				end
			else
				print = error
			end
		elseif not isEmpty(shortest) and mode1 == "shortest" then
			if mode2 == "nolink" then
				if mode3 == "sm" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					print = shortest
				else
					print = error
				end
			elseif mode2 == "sm" then
				if mode3 == "nolink" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
					elseif not isEmpty(link) then
						print = "<small>[[" .. link .. "|" .. shortest .. "]]</small>"
					else
						print = "<small>[[" .. medium .. "|" .. shortest .. "]]</small>"
					end
				else
					print = error
				end
			elseif isEmpty(mode2) then
				if not isEmpty(link) and not isEmpty(linkindicator) then
					print = "[[" .. link .. "|" .. linkindicator .. shortest .. "]]"
				elseif not isEmpty(linkindicator) then
					print = "[[" .. medium .. "|" .. linkindicator .. shortest .. "]]"
				elseif not isEmpty(link) then
					print = "[[" .. link .. "|" .. shortest .. "]]"
				else
					print = "[[" .. medium .. "|" .. shortest .. "]]"
				end
			else
				print = error
			end
		elseif mode1 == "sm" then
			if mode2 == "nolink" then
				if not isEmpty(short) and mode3 == "short" then
					print = "<small>''" .. short .. "''</small>"
				elseif not isEmpty(shorter) and mode3 == "shorter" then
					print = "<small>" .. shorter .. "</small>"
				elseif not isEmpty(shortest) and mode3 == "shortest" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					print = "<small>''" .. medium .. "''</small>"
				else
					print = error
				end
			elseif not isEmpty(short) and mode2 == "short" then
				if mode3 == "nolink" then
					print = "<small>''" .. short .. "''</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. short .. "'']]</small>"
					elseif not isEmpty(link) then
						print = "<small>''[[" .. link .. "|" .. short .. "]]''</small>"
					else
						print = "<small>''[[" .. medium .. "|" .. short .. "]]''</small>"
					end
				else
					print = error
				end
			elseif not isEmpty(shorter) and mode2 == "shorter" then
				if mode3 == "nolink" then
					print = "<small>" .. shorter .. "</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. shorter .. "]]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. shorter .. "]]</small>"
					elseif not isEmpty(link) then
						print = "<small>[[" .. link .. "|" .. shorter .. "]]</small>"
					else
						print = "<small>[[" .. medium .. "|" .. shorter .. "]]</small>"
					end
				else
					print = error
				end
			elseif not isEmpty(shortest) and mode2 == "shortest" then
				if mode3 == "nolink" then
					print = "<small>" .. shortest .. "</small>"
				elseif isEmpty(mode3) then
					if not isEmpty(link) and not isEmpty(linkindicator) then
						print = "<small>[[" .. link .. "|" .. linkindicator .. shortest .. "]]</small>"
					elseif not isEmpty(linkindicator) then
						print = "<small>[[" .. medium .. "|" .. linkindicator .. shortest .. "]]</small>"
					elseif not isEmpty(link) then
						print = "<small>[[" .. link .. "|" .. shortest .. "]]</small>"
					else
						print = "<small>[[" .. medium .. "|" .. shortest .. "]]</small>"
					end
				else
					print = error
				end
			elseif isEmpty(mode2) then
				if not isEmpty(link) and not isEmpty(linkindicator) then
					print = "<small>[[" .. link .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
				elseif not isEmpty(linkindicator) then
					print = "<small>[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]</small>"
				elseif not isEmpty(link) then
					print = "<small>''[[" .. link .. "|" .. medium .. "]]''</small>"
				else
					print = "<small>''[[" .. medium .. "]]''</small>"
				end
			else
				print = error
			end
		else
			print = error
		end
	elseif isEmpty(mode1) then
		if not isEmpty(link) and not isEmpty(linkindicator) then
			print = "[[" .. link .. "|"  .. linkindicator .. "''" .. medium .. "'']]"
		elseif not isEmpty(linkindicator) then
			print = "[[" .. medium .. "|" .. linkindicator .. "''" .. medium .. "'']]"
		elseif not isEmpty(link) then
			print = "''[[" .. link .. "|" .. medium .. "]]''"
		else
			print = "''[[" .. medium .. "]]''"
		end
	else
		print = error
	end
	return print
end

return p