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 game     = args.game 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.outputGameLink(game, link, short, shorter, shortest, mode1, mode2) end

function p.outputGameLink(game, link, short, shorter, shortest, mode1, mode2) local function isEmpty(s) return s == nil or s == '' end local print = '' if not isEmpty(mode1) then if not isEmpty(nolink) and 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 = "''" .. game .. "''"			end elseif not isEmpty(short) and mode1 == "short" then if not isEmpty(nolihk) and mode2 == "nolink" then print = "''" .. short .. "''"			elseif isEmpty(mode2) then print = "" .. short .. "" end elseif not isEmpty(shorter) and mode1 == "shorter" then if not isEmpty(nolink) and mode2 == "nolink" then print = shorter elseif isEmpty(mode2) then print = "" .. shorter .. "" end elseif not isEmpty(shortest) and mode1 == "shortest" then if not isEmpty(nolink) and mode2 == "nolink" then print = shortest elseif isEmpty(mode2) then print = "" .. shortest .. "" 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 print = "" .. game .. "" end return print end

return p