Jump to content

📢 Please make sure to read our Style Guide before editing. For questions, suggestions, or technical issues, please contact Noah.

Module:Infobox Player

From CrabCraft Wiki
Revision as of 16:01, 21 June 2025 by Noah (talk | contribs) (fixed categories)

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

local infobox = require('Module:Infobox')
local p = {}

local function humanLabel(name)
    return mw.ustring.gsub(mw.ustring.upper(mw.ustring.sub(name,1,1)) .. mw.ustring.sub(name,2), "%-", " ")
end

function p.infobox(frame)
    local args     = frame:getParent().args
    local outArgs  = { title = args.username, category1 = args.category1 }
    local count    = 0

    for key, val in pairs(args) do
        if key ~= 'username' and val and val ~= '' and key ~= 'category1' then
            count = count + 1
            outArgs['label'..count] = humanLabel(key)
            outArgs['data' ..count] = val
        end
    end

    outArgs.rows = count
    outArgs.categories = 1
    return infobox.infobox{
        getParent = function() return { args = outArgs } end
    }
end

return p