Module:MediumLink

local p = {}

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) 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 '' return p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2) end

function p.outputMediumLink(medium, link, short, shorter, shortest, mode1, mode2) local function isEmpty(s) return s == nil or s == '' end local print = '' local linkindicator = '' if medium == "Gekijōban Doubutsu no Mori" then linkindicator = "🎬 " end if not isEmpty(mode1) then if mode1 == "nolink" then if not isEmpty(short) and mode2 == "short" then print = "''" .. short .. "''"			elseif not isEmpty(shorter) and mode2 == "shorter" then print = shorter elseif not isEmpty(shortest) and mode2 == "shortest" then print = shortest elseif isEmpty(mode2) then print = "''" .. medium .. "''"			end elseif not isEmpty(short) and mode1 == "short" then if mode2 == "nolink" then print = "''" .. short .. "''"			elseif isEmpty(mode2) then if not isEmpty(link) then print = "" .. linkindicator .. "" .. short .. "" else print = "" .. linkindicator .. "" .. short .. "" end end elseif not isEmpty(shorter) and mode1 == "shorter" then if mode2 == "nolink" then print = shorter elseif isEmpty(mode2) then if not isEmpty(link) then print = "" .. linkindicator .. shorter .. "" else print = "" .. linkindicator .. shorter .. "" end end elseif not isEmpty(shortest) and mode1 == "shortest" then if mode2 == "nolink" then print = shortest elseif isEmpty(mode2) then if not isEmpty(link) then print = "" .. linkindicator .. shortest .. "" else print = "" .. linkindicator .. shortest .. "" end end else print = '\'\'\' Invalid parameters detected! Did you entered the wrong parameters or are the parameters needed to generate this game link empty? \'\'\''		end else if not isEmpty(link) then print = "" .. linkindicator .. "" .. medium .. "" elseif not isEmpty(linkindicator) then print = "" .. linkindicator .. "" .. medium .. "" else print = "" .. medium .. "" end end return print end

return p