×
Create a new article
Write your page title here:
We currently have 1,652 articles on The Quelmar Wiki. Type your article name above or click on one of the titles below and start writing!



The Quelmar Wiki
Revision as of 15:20, 23 January 2024 by Spiderjjr45 (talk | contribs) (Created page with "local p = {} function p.getCampaigns(frame) local wikitext = frame.args[1] -- Get the wikitext passed to the module local campaigns = { PA = {}, MD = {}, Online = {} } -- Function to process each campaign row local function processRow(row) local campaign, location = row:match("|'''%[%[(.-)%]%]'''%s*|%s*.-|.-|.-|.-|.-|.-|(.-)|") if campaign and location then if location:find("PA") then...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Documentation for this module may be created at Module:CampaignNavbox/doc

local p = {}

function p.getCampaigns(frame)
    local wikitext = frame.args[1] -- Get the wikitext passed to the module
    local campaigns = {
        PA = {},
        MD = {},
        Online = {}
    }

    -- Function to process each campaign row
    local function processRow(row)
        local campaign, location = row:match("|'''%[%[(.-)%]%]'''%s*|%s*.-|.-|.-|.-|.-|.-|(.-)|")
        if campaign and location then
            if location:find("PA") then
                table.insert(campaigns.PA, campaign)
            end
            if location:find("MD") then
                table.insert(campaigns.MD, campaign)
            end
            if location:find("Online") then
                table.insert(campaigns.Online, campaign)
            end
        end
    end

    -- Split the wikitext into rows and process each
    for row in wikitext:gmatch("|%-.-\n") do
        processRow(row)
    end

    -- Build the navbox
    local navbox = '{| class="wikitable"\n!Location\n!Campaigns\n'
    for loc, camps in pairs(campaigns) do
        navbox = navbox .. '|-\n|' .. loc .. '\n|' .. table.concat(camps, ', ') .. '\n'
    end
    navbox = navbox .. '|}'

    return navbox
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)
Cookies help us deliver our services. By using our services, you agree to our use of cookies. (Hi Margarita's Table. 🇩🇪)