Module:Abb

local p = {}

local gameList = { ['AR']    = "All Roads && All Roads", ['D20']   = "Fallout Pen and Paper d20 && Fallout d20", ['FB']    = "Fallout Bible", ['FBG']   = "Fallout: The Board Game", ['FBGNC'] = "Fallout: New California", ['FBGWW'] = "Fallout: Wasteland Warfare", ['FILM']  = "Fallout (film)", ['FNV']   = "Fallout: New Vegas", ['FNVCS'] = "Courier's Stash", ['FNVDM'] = "Dead Money", ['FNVGRA'] = "Gun Runners' Arsenal", ['FNVHH'] = "Honest Hearts", ['FNVLR'] = "Lonesome Road (add-on) && Lonesome Road", ['FNVOWB'] = "Old World Blues (add-on) && Old World Blues", ['FO4']   = "Fallout 4", ['FO4AUT'] = "Automatron (add-on) && Automatron", ['FO4WW'] = "Wasteland Workshop", ['FO4FH'] = "Far Harbor (add-on) && Far Harbor", ['FO4CW'] = "Contraptions Workshop", ['FO4VW'] = "Vault-Tec Workshop", ['FO4NW'] = "Nuka-World (add-on) && Nuka-World", ['FO4VR'] = "Fallout 4 VR", ['FO4CC'] = "Creation Club", ['FOS']   = "Fallout Shelter", ['FPB']   = "Fallout Pip-Boy", ['FO']    = "Fallout", ['FO1']   = "Fallout", ['FO2']   = "Fallout 2", ['FO3']   = "Fallout 3", ['FO3BS'] = "Broken Steel", ['FO3MZ'] = "Mothership Zeta {add-on) && Mothership Zeta",    ['FO3OA']  = "Operation Anchorage (add-on) && Operation Anchorage",    ['FO3PL']  = "Point Lookout (add-on) && Point Lookout",    ['FO3TP']  = "The Pitt (add-on) && The Pitt",    ['FO76']   = "Fallout 76",    ['FO76WA'] = "Wild Appalachia",    ['FO76NW'] = "Nuclear Winter",    ['FO76WL'] = "Wastelanders",    ['FOBOS']  = "Fallout: Brotherhood of Steel && Fallout: BoS",    ['FOBOS2'] = "Fallout: Brotherhood of Steel 2 && Fallout: BoS 2",    ['FOOL']   = "Project V13",    ['PV13']   = "Project V13",    ['FOT']    = "Fallout Tactics: Brotherhood of Steel && Fallout Tactics",    ['FOT2']   = "Fallout Tactics 2",    ['FOW']    = "Fallout: Warfare",    ['FOX']    = "Fallout Extreme",    ['FWW']    = "Fallout: Wasteland Warfare",    ['JES']    = "J.E. Sawyer's Fallout RPG && JES Fallout RPG",    ['LH']     = "Lionheart",    ['PA']     = "One Man, and a Crate of Puppets && Penny Arcade", ['TAR']   = "The Armageddon Rag && Armageddon Rag", ['TORN']  = "TORN", ['VB']    = "Van Buren", ['WIKI']  = "Fallout Wiki:About", ['NONE']  = "Mentioned-only", ['RW']    = "Real world" }

local abbIcon = { ["AR"]             = "gametitle-AR.png", ["D20"]            = "gametitle-D20.png", ["FB"]             = "gametitle-FB.png", ["FBG"]            = "gametitle-FBG.png", ["FBGNC"]          = "gametitle-FBGNC.png", ["FBGWW"]          = "gametitle-FBGWW.png", ["FILM"]           = "Film.png", ["FNV"]            = "gametitle-FNV.png", ["FNVCS"]          = "Gametitle-FNV CS.png", ["FNVDM"]          = "gametitle-FNV DM.png", ["FNVGRA"]         = "gametitle-FNV GRA.png", ["FNVHH"]          = "gametitle-FNV HH.png", ["FNVLR"]          = "gametitle-FNV LR.png", ["FNVOWB"]         = "gametitle-FNV OWB.png", ["FO"]             = "gametitle-FO1.png", ["FO1"]            = "gametitle-FO1.png", ["FO2"]            = "gametitle-FO2.png", ["FO3"]            = "gametitle-FO3.png", ["FO3BS"]          = "gametitle-FO3 BS.png", ["FO3MZ"]          = "gametitle-FO3 MZ.png", ["FO3OA"]          = "gametitle-FO3 OA.png", ["FO3PL"]          = "gametitle-FO3 PL.png", ["FO3TP"]          = "gametitle-FO3 TP.png", ["FO4"]            = "gametitle-FO4.png", ["FO4AUT"]         = "gametitle-FO4 AUT.png", ["FO4CC"]          = "gametitle-FO4 CC.png", ["FO4CW"]          = "gametitle-FO4_CW.png", ["FO4FH"]          = "gametitle-FO4_FH.png", ["FO4NW"]          = "gametitle-FO4_NW.png", ["FO4VR"]          = "gametitle-FO4VR.png", ["FO4VW"]          = "gametitle-FO4 VW.png", ["FO4WW"]          = "gametitle-FO4 WW.png", ["FO76"]           = "gametitle-FO76.png", ["FO76WA"]         = "gametitle-FO76 WA.png", ["FO76NW"]         = "gametitle-FO76 NW.png", ["FO76WL"]         = "gametitle-FO76 WL.png", ["FOBOS"]          = "gametitle-FOBOS.png", ["FOBOS2"]         = "gametitle-FOBOS2.png", ["FOOL"]           = "PV13.png", ["FOS"]            = "gametitle-FOS.png", ["FOT"]            = "gametitle-FOT.png", ["FOT2"]           = "gametitle-FOT2.png", ["FOW"]            = "gametitle-FOW.png", ["FOX"]            = "gametitle-FOX.png", ["FPB"]            = "gametitle-FPB.png", ["FWW"]            = "gametitle-FWW.png", ["JES"]            = "gametitle-JES.png", ["LH"]             = "gametitle-LH.png", ["PA"]             = "Penny Arcade.gif", ["PV13"]           = "PV13.png", ["TAR"]            = "gametitle-TAR.jpg", ["TORN"]           = "gametitle-TORN.png", ["VB"]             = "gametitle-VB.png", ["WIKI"]           = "gametitle-Wiki.png", }

function abbOnly(abbGames, mode, abbLength) local gamesCount = 1 local gameOut = "" while gamesCount <= abbLength do       local activeGame = abbGames[gamesCount] local gameText = mw.text.split(gameList[activeGame], " && ") if mode == "link" or mode == "text" or mode == nil then gameOut = gameOut .. gameText[1] else if gameText[2] ~= nil then gameOut = gameOut .. gameText[2] else gameOut = gameOut .. gameText[1] end end if gamesCount ~= abbLength then gameOut = gameOut .. " "       end gamesCount = gamesCount + 1 end if gameOut == nil then gameOut = "Failed" end return gameOut end

function abbFile(abbGames, abbLength) local fileCount = 1 local fileOut = "" while fileCount <= abbLength do       currentFile = string.upper(abbGames[fileCount]) currentFile = abbIcon[currentFile] if currentFile ~= nil then fileOut = fileOut .. currentFile end fileCount = fileCount + 1 end return fileOut end

function abbCategory(abbGames, abbLength, abbCatName, abbAppend, abbPrepend, abbCatMode, abbSort) local catCount = 1 local catOut = "" while catCount <= abbLength do       currentCat = abbGames[catCount] currentCat = gameList[currentCat] if currentCat ~= nil then catOut = catOut .. "[[Category:"           if string.lower(abbCatMode) == append then                catOut = catOut .. string.lower(abbCatName) .. " "                if abbCatAppend ~= nil then                    catOut = catOut .. abbAppend                end                catOut = catOut ..  currentCat                if abbCatPrepend ~= nil then                    catOut = catOut .. abbPrepend                end            else                catOut = catOut .. currentCat .. " "                if abbCatAppend ~= nil then                    catOut = catOut .. " " .. abbAppend                end                catOut = catOut .. abbCatName                if abbCatPrepend ~= nil then                    catOut = catOut .. abbPrepend                end            end            if abbSort ~= nil then                catOut = catOut .. "|" .. abbSort            end            catOut = catOut .. "]]" end catCount = catCount + 1 end return catOut end

function p.abb(frame) if frame.args[2] ~= nil then mode = string.lower(frame.args[2]) end local games = string.upper(tostring(frame.args[1])) games = mw.text.split(games, ",") length = table.getn(games) if mode == "link" or mode == "text" or mode == "short" or mode == nil then result = abbOnly(games, mode, length) end

if mode == "cat" then abbCatName = frame.args[3] abbAppend = frame.args[4] abbPrepend = frame.args[5] abbCatMode = frame.args[6] abbSort = frame.args[7] result = abbCategory(games, length, abbCatName, abbAppend, abbPrepend, abbCatMode, abbSort) end

if mode == "icon" then result = abbFile(games, length) end return result end

function p.loaded result = package.loaded return result end

return p