Module:SfxTabber

From The Gimkit Wiki

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

local p = {}

-- Stolen from google
local function firstToUpper(str)
    return (str:gsub("^%l", string.upper))
end

p.generate = function(frame)
    local str = ""
    local div = '<div style="display: flex; flex-wrap: wrap; gap: 5px;">'
    local first = true

    for name, amount in pairs(frame.args) do
        amount = tonumber(amount)
        if name ~= "basefilename" then
            -- Add the tab and div
            if first then
                str = str .. firstToUpper(name) .. "=\n" .. div .. "\n"
            else
                str = str .. "\n|-|" .. firstToUpper(name) .. "=\n" .. div .. "\n"
            end

            -- Add the images
            for i = 1, amount do
                str = str .. "[[File:" .. frame.args.basefilename .. '_' .. name .. i .. ".mp3]]\n"
            end

            -- Close the div
            str = str .. "</div>"

            first = false
        end
    end

    return frame:extensionTag{ name="tabber", content=str }
end

return p