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" }

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 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 == "icon" then local icons = require("Module:Icons") if frame.args[3] ~= nil then abbSize = tostring(frame.args[3]) else abbSize = "medium" end

result = icons.Icons(FO4, abbSize) 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

return result end

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

return p