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"] = "DGIcon.png", ["Accepted"] = {"Dream Game","DG","Frozen Soul"} },       ["The Forge and the Crucible"] = { ["Image"] = "ForgeIcon.png", ["Accepted"] = {"Forge","The Forge and the Crucible","TFatC"} },       ["Ghostright"] = { ["Image"] = "GhostrightIcon.png", ["Accepted"] = {"Ghostright"} -- I don't really think this nor the others can be shortened much anyway },       ["Roulette Saloon"] = { ["Image"] = "RouletteIcon.png", ["Accepted"] = {"Roulette","Roulette Saloon"} },       ["Wizard Warz"] = { ["Image"] = "WizardWarzIcon.png", ["Accepted"] = {"Wizard Warz"} },       ["Epic Department"] = { ["Image"] = "Epic1.webp", ["Accepted"] = {"Epic Department","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 covers content in all Dreamsphere 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 ContentOf:find(AcceptedName) then if checkduplicate(Game) == false then table.insert(AlreadyPassed,Game) ReturnedResult = ReturnedResult .. format(Game) .. " / "               end end end end return (ReturnedResult:sub(1,(string.len(ReturnedResult)-2)) .. "Content") -- The weird string.sub is just me not knowing how to remove the last "/"... end return p