Module:Abb

local p = {} local util = require( 'Module:Util' )

local gameList = { FORPGQS = { icon = "Infobox.png", title = "Fallout: The Roleplaying Game Quickstart", short = "FORPG Quickstart" },

FORPGSS = { icon = "Infobox.png", title = "Fallout: The Roleplaying Game Starter Set", short = "FORPG Starter Set" },

FORPGGM = { icon = "Infobox.png", title = "Fallout: The Roleplaying Game Gamemaster's Toolkit", short = "Gamemaster's Toolkit" },  FORPGGMS = { icon = "Infobox.png", title = "Fallout: The Roleplaying Game GM Screen", short = "GM Screen" },   FORPGUPON = { icon = "Infobox.png", title = "Once Upon a Time in the Wasteland", short = "Once Upon a Time in the Wasteland" },

AR = { icon = "Infobox.png", title = "All Roads", short = "All Roads" },

AOTL = { icon = "AttackOfTheLobotomitesLogocut.png", title = "Attack of the Lobotomites!", link = "Mod:Attack of the Lobotomites!|Attack of the Lobotomites!", short = "Attack of the Lobotomites!" },

AR1 = { icon = "Infobox.png", title = "America Rising", link = "Mod:America Rising - A Tale of the Enclave|America Rising - A Tale of the Enclave", short = "America Rising 2" },

AR2 = { icon = "Infobox.png", title = "America Rising 2", link = "Mod:America Rising 2 - Legacy of the Enclave|America Rising 2 - Legacy of the Enclave", short = "America Rising 2" },

bonezone = { icon = "Upper_skull.png", title = "THE BONE ZONE", link = "Community:The Bone Zone|The Bone Zone", short = "THE BONE ZONE" },

D20 = { icon = "Infobox.png", title = "Fallout Pen and Paper d20", link = "Fallout d20", short = "Fallout d20" },

FB = { icon = "Fallout_Bible_logo.png", title = "Fallout Bible" },

FBG = { icon = "Fallout The Board Game Icon.png", title = "Fallout: The Board Game" },

FBGNC = { icon = "Gametitle-FBGNC.png", title = "Fallout: New California" },   FOWW = { icon = "FOWW Logo.png", title = "Fallout: Wasteland Warfare", },   FWW = { icon = "FOWW Logo.png", title = "Fallout: Wasteland Warfare", },   FWWROP = { icon = "FOWW Logo.png", title = "Campaign Handbook", short = "FWW Campaign Handbook" },   FWWGA = { icon = "FOWW Logo.png", title = "Getting Acclimated", short = "FWW Getting Acclimated" },   FWWROP = { icon = "FOWW Logo.png", title = "Rules of Play", short = "FWW Rules of Play" },   FWWBM = { icon = "FOWW Logo.png", title = "Battle Mode", },   FWWCOH = { icon = "FOWW Logo.png", title = "Co-Op Handbook", },   FWWAIH = { icon = "FOWW Logo.png", title = "AI Handbook", },   FWWRPG = { icon = "FOWW RPG Logo.png", title = "Fallout: Wasteland Warfare Roleplaying Game", },   FWWCITC = { icon = "FOWW Logo.png", title = "Caught in the Crossfire", },   FWWITW = { icon = "FOWW Logo.png", title = "Into the Wasteland", },   FWWRPGTUS1 = { icon = "FOWW RPG Logo.png", title = "The Unexpected Shepherd Part 1: Protection Order", short = "TUS Part 1: Protection Order" },   FWWRPGMF = { icon = "FOWW RPG Logo.png", title = "Machine Frequency", },   FWWNV = { icon = "FOWW Logo.png", title = "New Vegas Rules", },   FWWCM = { icon = "FOWW Logo.png", title = "Commonwealth Rules", },   FWWAAT1 = { icon = "FOWW Logo.png", title = "Astoundingly Awesome Tales, #1", },   FWWITV = { icon = "FOWW Logo.png", title = "Into the Vault", },   FWWRPGTUS2 = { icon = "FOWW RPG Logo.png", title = "The Unexpected Shepherd Part 2: Dangerous Trails", short = "TUS Part 2: Dangerous Trails" },   FWWRPGTUS3 = { icon = "FOWW RPG Logo.png", title = "The Unexpected Shepherd Part 3: Battle Station", short = "TUS Part 3: Battle Station" },   FWWHS = { icon = "FOWW Logo.png", title = "Homestead Rules", },   FWWFITF = { icon = "FOWW Logo.png", title = "Forged in the Fire Rules", },   FWWCP = { icon = "FOWW Logo.png", title = "Capital Rules", },   FWWNW = { icon = "FOWW Logo.png", title = "Nuka-World Rules", },   FWWAAT2 = { icon = "FOWW Logo.png", title = "Astoundingly Awesome Tales, #2", },   FOFNW = { icon = "FOFNW Logo.png", title = "Fallout Factions: Nuka World", },   FILM = { icon = "Infobox.png", title = "Fallout (film)" },

FNV = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas" },   FNVCS = { icon = "Gametitle-FNV_CS.png", title = "Courier's Stash" },

FNVDM = { icon = "Gametitle-FNV_DM.png", title = "Dead Money" },   FNVGRA = { icon = "Gametitle-FNV_GRA.png", title = "Gunn Runners' Arsenal" },

FNVHH = { icon = "Gametitle-FNV_HH.png", title = "Honest Hearts" },

FNVLR = { icon = "Gametitle-FNV_LR.png", title = "Lonesome Road (add-on)", link = "Lonesome Road", short = "Lonesome Road" },

FNVOWB = { icon = "Gametitle-FNV_OWB.png", title = "Old World Blues (add-on)", link = "Old World Blues", short = "Old World Blues" },

FO4 = { icon = "Gametitle-FO4.png", title = "Fallout 4", },

FO4AUT = { icon = "Gametitle-FO4_AUT.png", title = "Automatron (add-on)", link = "Automatron", short = "Automatron" },

FO4WW = { icon = "Gametitle-FO4_WW.png", title = "Wasteland Workshop" },

FO4FH = { icon = "Gametitle-FO4_FH.png", title = "Far Harbor (add-on)", link = "Far Harbor", short = "Far Harbor" },

FO4CW = { icon = "Gametitle-FO4_CW.png", title = "Contraptions Workshop" },

FO4VW = { icon = "Gametitle-FO4_VW.png", title = "Vault-Tec Workshop" },

FO4NW = { icon = "Gametitle-FO4_NW.png", title = "Nuka-World (add-on)", link = "Nuka-World", short = "Nuka-World" },

FO4CC = { icon = "Gametitle-FO4_CC.png", title = "Creation Club" },   FOS = { icon = "Gametitle-FOS.png", title = "Fallout Shelter", },    FOSO = { icon = "Gametitle-FOSO.png", title = "Fallout Shelter Online", },

FPB = { icon = "Gametitle-FPB.png", title = "Fallout Pip-Boy" },

FO = { icon = "Gametitle-FO1.png", title = "Fallout" },

FO1 = { icon = "Gametitle-FO1.png", title = "Fallout" },

FO2 = { icon = "Gametitle-FO2.png", title = "Fallout 2" },

FO3 = { icon = "Gametitle-FO3.png", title = "Fallout 3" },

FO3BS = { icon = "Gametitle-FO3_BS.png", title = "Broken Steel" },

FO3MZ = { icon = "Gametitle-FO3_MZ.png", title = "Mothership Zeta", link = "Mothership Zeta", short = "Mothership Zeta" },

FO3OA = { icon = "Gametitle-FO3_OA.png", title = "Operation: Anchorage", link = "Operation: Anchorage", short = "Operation: Anchorage" },

FO3PL = { icon = "Gametitle-FO3_PL.png", title = "Point Lookout (add-on)", link = "Point Lookout", short = "Point Lookout" },

FO3TP = { icon = "Gametitle-FO3_TP.png", title = "The Pitt (add-on)", link = "The Pitt", short = "The Pitt" },

FO76 = { icon = "Gametitle-FO76.png", title = "Fallout 76", link = "Fallout 76" },

FO76WA = { icon = "Gametitle-FO76_WA.png", title = "Wild Appalachia" },

FO76NW = { icon = "Gametitle-FO76_NW.png", title = "Nuclear Winter", link = "Nuclear Winter" },   FO76WL = { icon = "Gametitle FO76WL.png", title = "Wastelanders" },

FO76LR = { icon = "Gametitle-FO76_LR.png", title = "The Legendary Run (update)", link = "The Legendary Run", short = "The Legendary Run" },

FO76OW = { icon = "Gametitle-FO76_One_Wasteland.png", title = "One Wasteland For All" },

FO76FS = { icon = "Gametitle-FO76_Steel Dawn.png", title = "Steel Dawn", link = "Steel Dawn" },

FO76SD = { icon = "Gametitle-FO76_Steel Dawn.png", title = "Steel Dawn", link = "Steel Dawn" },

FO76LL = { icon = "Gametitle-FO76_Locked n Loaded.png", title = "Locked & Loaded" },   FO76SR = { icon = "Gametitle-FO76_Steel Reign.png", title = "Steel Reign", link = "Steel Reign" },   FO76FW = { icon = "Gametitle-FO76 FW.png", title = "Fallout Worlds", link = "Fallout Worlds" },   FO76ETP = { icon = "Gametitle-FO76.png", title = "Expeditions: The Pitt" },

FO76RD = { icon = "Gametitle-FO76.png", title = "Rip Daring and the Cryptid Hunt", link = "Rip Daring and the Cryptid Hunt" },

FO76MI = { icon = "Gametitle-FO76.png", title = "Mutation Invasion", link = "Mutation Invasion" },

FO76OBM = { icon = "Gametitle-FO76.png", title = "Once in a Blue Moon", link = "Once in a Blue Moon" },   FO76AC = { icon = "Gametitle-FO76.png", title = "Expeditions: Atlantic City", link = "Expeditions: Atlantic City" },

FOBOS = { icon = "Gametitle-FOBOS.png", title = "Fallout: Brotherhood of Steel", link = "Fallout: Brotherhood of Steel", short = "Fallout: BOS" },

FOBOS2 = { icon = "Infobox.png", title = "Fallout: Brotherhood of Steel 2", link = "Fallout: Brotherhood of Steel 2", short = "Fallout: BOS 2" },

FO4 = { icon = "Gametitle-FO4.png", title = "Fallout 4", },

FO5 = { icon = "Infobox.png", title = "Fallout 5" },

PV13 = { icon = "Infobox.png", title = "Project V13" },

FOT = { icon = "Gametitle-FOT.png", title = "Fallout Tactics", link = "Fallout Tactics", short = "Fallout Tactics" },   FOT2 = { icon = "Infobox.png", title = "Fallout Tactics 2" },

FOW = { icon = "Infobox.png", title = "Fallout: Warfare" },

FOX = { icon = "Infobox.png", title = "Fallout Extreme" },

FOWW = { icon = "Gametitle-FWW.png", title = "Fallout: Wasteland Warfare" },   JES = { icon = "Infobox.png", title = "J.E. Sawyer's Fallout RPG", short = "JES Fallout RPG" },

LH = { icon = "Infobox.png", title = "Lionheart" },

PA = { icon = "Infobox.png", title = "One Man, and a Crate of Puppets", short = "Penny Arcade" },

TAR = { icon = "Infobox.png", title = "The Armageddon Rag", short = "Armageddon Rag" },   TORN = { icon = "Infobox.png", title = "TORN" },   VB = { icon = "Van Buren Fallout 3 Logo.png", title = "Van Buren" },

WIKI = { icon = "Infobox.png", title = "FalloutWiki:About", short = "Fallout Wiki" },   NONE = { title = "mentioned-only" },

RW = { title = "real world" },

FNVCE = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas Official Game Guide", link = "Fallout: New Vegas Official Game Guide" },

FNVCE1 = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas Official Game Guide: Behind the Bright Lights & Big City", link = "Fallout: New Vegas Official Game Guide/Behind the Bright Lights & Big City", short = "Behind the Bright Lights & Big City" },

FNVCE2 = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas Official Game Guide: Wild Wasteland Oddities", link = "Fallout: New Vegas Official Game Guide/Wild Wasteland Oddities", short = "Wild Wasteland Oddities" },

FNVCE3 = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas Official Game Guide: Tour of the Mojave Wasteland", link = "Fallout: New Vegas Official Game Guide/Tour of the Mojave Wasteland", short = "Tour of the Mojave Wasteland" },

FNVCE4 = { icon = "Gametitle-FNV.png", title = "Fallout: New Vegas Official Game Guide: Faction Profiles", link = "Fallout: New Vegas Official Game Guide/Faction Profiles", short = "Faction Profiles" },

DOA   = { icon = "Dawn of America logo.png", title = "Dawn of America", link = "Mod:Dawn of America", short = "Dawn of America" },

DUST   = { icon = "Mod_DUST_Logo.jpg", title = "DUST", link = "Mod:DUST Survival Simulator", short = "DUST" },

FNC  = { icon = "Mod New California logo main page.png", title = "Fallout: New California mod", link = "Mod:Fallout: New California", short = "Fallout: New California mod" },

DIZ   = { icon = "Diz Icon.png", title = "DiZco12's Lightweight Lore-Friendly Overhaul", link = "Mod:DiZco12's Lightweight Lore-Friendly Overhaul", short = "DiZco12's Lightweight Lore-Friendly Overhaul" },

MPFO3 = { icon = "MadeMan.svg", title = "More Perks for Fallout 3" },   MPREQ = { icon = "MadeMan.svg", title = "More Perks Requested for Fallout 3" },   MPOA = { icon = "MadeMan.svg", title = "More Perks for Operation Anchorage" },   MPTP = { icon = "MadeMan.svg", title = "More Perks for The Pitt" },   MPBS = { icon = "MadeMan.svg", title = "More Perks for Broken Steel" },   MPPL = { icon = "MadeMan.svg", title = "More Perks for Point Lookout" },   MPMZ = { icon = "MadeMan.svg", title = "More Perks for Mothership Zeta" },   MPFNV = { icon = "MadeMan.svg", title = "More Perks for Fallout: New Vegas" },   MPCMP = { icon = "MadeMan.svg", title = "More Perks for Companions" },   MPMT = { icon = "MadeMan.svg", title = "More Traits for Fallout: New Vegas" },   MPDM = { icon = "MadeMan.svg", title = "More Perks for Dead Money" },   MPHH = { icon = "MadeMan.svg", title = "More Perks for Honest Hearts" },   MPOWB = { icon = "MadeMan.svg", title = "More Perks for Old World Blues" },   MPDF = { icon = "MadeMan.svg", title = "Deserter's Fortress" }, }

function setTable(keys) if string.len(tostring(keys)) > 0 then result = mw.text.split(keys, ",") else result = nil end return result end

function _valid(games) local keys = setTable(games) for k, v in ipairs(keys) do       if gameList[v] ~=nil then return true end end return false end

function p.i_valid(games) return _valid(games) end

function p.validation(frame) return _valid(frame.args['games']) end

function icon(frame) 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 _category(keys, category, prepend, append, mode, sortkey) local keys = setTable(keys) local result = "" if util.exists(keys) then for k, v in ipairs(keys) do           local currentCat = nil if util.exists(gameList[v].link) then currentCat = gameList[v].link else currentCat = gameList[v].title end result = result .. "[[Category:"

if util.exists(mode) and string.lower(mode) == "append" then result = result .. string.lower(category) .. " "               if util.exists(prepend) then result = result .. prepend end

result = result .. currentCat

if util.exists(append) then result = result .. append end else result = result .. currentCat .. " "               if util.exists(prepend) then result = result .. " " .. prepend end result = result .. category if util.exists(append) then result = result .. append end end

if util.exists(sortKey) then result = result .. "|" .. sortKey end result = result .. "]]"       end else result = "[[Category:" .. category       if exists(sortKey) then                result = result .. "|" .. sortKey        end        result = result .. "]]" end return result end

function p.i_category(games, category, prepend, append, mode, sortkey) return _category(games, category, prepend, append, mode, sortkey) end

function p.category(frame) local keys = setTable(frame.args['games']) local category = frame.args['category'] local prepend = frame.args['prepend'] local append = frame.args['append'] local mode = frame.args['mode'] local sortKey = frame.args['sort key'] local i = 1 local result = "" if keys ~= nil then while i <= table.getn(keys) do           local currentCat = nil currentCat = keys[i] if gameList[currentCat]['link'] ~= nil then currentCat = gameList[currentCat]['link'] else currentCat = gameList[currentCat]['title'] end result = result .. "[[Category:"

if string.lower(mode) == "append" then result = result .. string.lower(category) .. " "               if prepend ~= nil then result = result .. prepend end

result = result .. currentCat

if append ~= nil then result = result .. append end else result = result .. currentCat .. " "               if prepend ~= nil then result = result .. " " .. prepend end result = result .. category if append ~= nil then result = result .. append end end

if sortKey ~= nil and string.len(sortKey) ~= 0 then result = result .. "|" .. sortKey end result = result .. "]]"           i = i + 1 end else result = "[[Category:" .. category       if sortKey ~= nil and string.len(sortKey) ~= 0 then                result = result .. "|" .. sortKey        end        result = result .. "]]" end return result 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.documentation keys = {} for k in pairs(gameList) do       table.insert(keys, k)    end table.sort(keys) result = '{| class="ace-table ace-table-full"\n|-\n !Abbreviation!!text/title!!short!!link!!icon\n|-\n' for k,v in ipairs(keys) do result = result .. '|' .. v .. '||' .. gameList[v].title .. '||'		if _valid(gameList[v].short) ~= nil then result = result .. gameList[v].short else result = result .. gameList[v].title end result = result .. '||'		if _valid(gameList[v].link) ~= nil then result = result .. gameList[v].link else result = result .. gameList[v].title end result = result .. '||' .. '\n|-\n' end result = result .. '\n|}' return result end

return p