Module:Games

local p = {}

local games = { ["AR"] = "All Roads", ["D20"] = "Fallout Pen and Paper d20 creatures", ["FO1"] = "Fallout", ["FO2"] = "Fallout 2", ["FO3"] = "Fallout 3", ["FO3OA"] = "Operation: Anchorage", ["FO3TP"] = "The Pitt", ["FO3BS"] = "Broken Steel", ["FO3PL"] = "Point Lookout", ["FO3MZ"] = "Mothership Zeta", ["FNV"] = "Fallout: New Vegas", ["FNVGRA"] = "Gun Runners' Arsenal", ["FNVDM"] = "Dead Money", ["FNVHH"] = "Honest Hearts", ["FNVOWB"] = "Old World Blues", ["FNVLR"] = "Lonesome Road", ["FO4"] = "Fallout 4", ["FOS"] = "Fallout Shelter", ["FOT"] = "Fallout Tactics", ["FOT2"] = "Fallout Tactics 2", ["FOBOS"] = "Fallout: Brotherhood of Steel", ["FOBOS2"] = "Fallout: Brotherhood of Steel 2", ["PA"] = "One Man, and a Crate of Puppets creatures", ["VB"] = "Van Buren", ["FILM"] = "Fallout (film)", ["FOX"] = "Fallout Extreme", ["JES"] = "J.E. Sawyer's Fallout Role-Playing Game", ["PV13"] = "Project V13", ["FB"] = "Fallout Bible", ["TAR"] = "Project V13", ["LH"] = "Lionheart", }

function ftrim(str, char) local first = string.sub(str, 1, 1) if first == char then return string.sub(str, 2) else return str end end

-- ==================== -- -- This function, links, is for ordinary links within the body of -- -- an infobox. So if all you want returned is Fallout 4, then -- -- use the syntax: -- --        -- -- ==================== --

function p.links(frame) local result = '' for game in string.gmatch(frame.args[1], '([^,]+)') do       if game:lower == "none" then result = '' else result = result .. '' .. games[ftrim(game, ' ')] .. ' ' end end if result == '' then return '' else return frame:preprocess(string.sub(result, 1, string.len(result) - 5)) end end

-- ================ -- -- The following functions are for the special use cases -- -- of a link to a particular "overview" page about an aspect -- -- of a game. These functions generate links in the title that -- -- take you to places like Fallout 2 locations or -- -- Fallout 3 characters. They are what used to be -- -- called around these parts "supertitle links". -- -- =============== --

-- Title function --

-- This is a function that generically inserts a link into -- -- a supertitle. It's actually broken and will be phased out. -- -- It doesn't give you a link to Fallout 4 weapons but -- -- just Fallout 4. Still, it needs to be kept around -- -- until all the individual functions, below, have -- -- been completed.

-->

function p.title(frame) local result = '' for game in string.gmatch(frame.args[1], '([^,]+)') do       if game:lower == "none" then result = 'Mentioned-only' else result = result .. '' .. games[ftrim(game, ' ')] .. ' / ' end end if result == 'Mentioned-only' then return result else return frame:preprocess(string.sub(result, 1, string.len(result) - 3)) end end

-- Character --

-- For use only with -- -- Template:Infobox_character --

-- (All of the functions below -- -- are to be used only with -- -- the infobox template of -- -- the same name --

function p.character(frame) local result = '' for game in string.gmatch(frame.args[1], '([^,]+)') do       if game:lower == "none" then result = 'Mentioned-only' else result = result .. '' .. games[ftrim(game, ' ')] .. ' / ' end end if result == 'Mentioned-only' then return result else return frame:preprocess(string.sub(result, 1, string.len(result) - 3)) end end

-- Location --

function p.location(frame) local result = '' for game in string.gmatch(frame.args[1], '([^,]+)') do       if game:lower == "none" then result = 'Mentioned-only' else result = result .. '' .. games[ftrim(game, ' ')] .. ' / ' end end if result == 'Mentioned-only' then return result else return frame:preprocess(string.sub(result, 1, string.len(result) - 3)) end end

return p