Module:ContentOf

local p = {}

function p.ReturnListofGames(frame) local GamesList = { -- Example Entry       ["Game Name"] = {            ["Image"] = "File:GameIcon.(extension)" / replace (extension) with something like .PNG or .webp            ["Accepted"] = {"Game Name","GN", and so on...} / This defines parameters. i.e. DG --> Dream Game, FatC - Forge and the Crucible        }        -- ["Dream Game"] = { ["Image"] = "DGLogo2.png", ["Accepted"] = {"dream game", "dg", "frozen soul"} },       ["The Forge and the Crucible"] = { ["Image"] = "ForgeLogo2.png", ["Accepted"] = {"forge", "the forge and the crucible", "forge and the crucible", "tfatc"} },       ["Ghostright"] = { ["Image"] = "GRLogo2.png", ["Accepted"] = {"ghostright", "gr"} },       ["Roulette Saloon"] = { ["Image"] = "RouletteLogo2.png", ["Accepted"] = {"roulette saloon", "roulette", "saloon", "rs"} },       ["Wizard Warz"] = { ["Image"] = "WWLogo2.png", ["Accepted"] = {"wizard warz", "wizard wars", "ww"} },       ["Viper Enclave"] = { ["Image"] = "ViperLogo3.png", ["Accepted"] = {"viper enclave", "viper", "ve"} },       ["Nevermoor's Murder Mystery"] = { ["Image"] = "NevermoorIcon2.png", ["Accepted"] = {"nevermoor", "nevermoor's", "nevermoor murder mystery", "nevermoor's murder mystery", "nevermoor's murder", "murder", "murder mystery", "nmm"} },       ["Minigame World: Reborn"] = { ["Image"] = "MWLogo2.png", ["Accepted"] = {"minigame world reborn", "minigame world: reborn", "minigames world reborn", "minigames world: reborn", "minigame world", "minigames world", "minigame", "minigames", "mgwr", "mwr", "mg"} },       ["Thieves in the House"] = { ["Image"] = "TITHLogo2.png", ["Accepted"] = {"thieves in the house", "thieves", "tith"} },       ["Humanoid Harvester Horror"] = { ["Image"] = "HHHLogo2.png", ["Accepted"] = {"humanoid harvester horror", "humanoid harvestor horror", "hhh", "cheeseburger apocalypse"} },       ["Epic Department"] = { ["Image"] = "Epic1.webp", ["Accepted"] = {"epic department", "epic", "ed"} }   }    local ContentOf = frame.args["Games"] local AlreadyPassed = {} local ReturnedResult = ""

local function format(Parameter) -- Returns a parsed/formatted game link. return " " .. Parameter .. " " end local function checkduplicate(Name) -- Ensures that entries don't get duplicated e.g. Forge and The Forge and the Crucible returning Forge twice. local Duplicate = false for _,Value in ipairs(AlreadyPassed) do           if Value == Name then Duplicate = true end end return Duplicate end -- Checks if the parameter passed was empty if ContentOf == "" then error("No parameter passed to module?") end

-- For all Dreamsphere games if string.lower(ContentOf) == "all" then for Game, _ in pairs(GamesList) do if Game ~= "Epic Department" then -- Exception from the "All" parameter. ReturnedResult = ReturnedResult .. "  "            end end ReturnedResult = ReturnedResult .. " This page contains content for all Dreamsphere-related games." return ReturnedResult end

-- Selected games using the Accepted parameters in the GamesList table for Game, _ in pairs(GamesList) do       for _,AcceptedName in ipairs(GamesList[Game]["Accepted"]) do            if string.lower(ContentOf):find(AcceptedName) then if checkduplicate(Game) == false then table.insert(AlreadyPassed,Game) ReturnedResult = ReturnedResult .. format(Game) .. " and " end end end end return ("This page contains content for " .. ReturnedResult:sub(1,(string.len(ReturnedResult)-4)) .. ".") -- The weird string.sub is just me not knowing how to remove the last "/"... end return p