Module:Test: Difference between revisions

From roblox chads wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
local capiunto = require 'capiunto'
local capiunto = require 'capiunto'


Line 4: Line 5:


function p.main(frame)
function p.main(frame)
local args = frame:getParent().args
    local args = frame:getParent().args
local headerStyle
 
if args.headerstyle and args.headerstyle ~= '' then
    local headerStyle
headerStyle = string.format('background-color:%s;', args.headerstyle)
    if args.headerstyle and args.headerstyle ~= '' then
else
        headerStyle = string.format('background-color:%s;', args.headerstyle)
headerStyle = 'background-color:#a1dbff;'
    else
end
        headerStyle = 'background-color:#a1dbff;'
local retval = capiunto.create( {
    end
title = args.title,
 
headerStyle = headerStyle,
    local retval = capiunto.create({
} )
        title = args.title,
:addImage( args.image, args.caption )
        headerStyle = headerStyle,
     for i,v in pairs(args) do
    }):addImage(args.image, args.caption)
         if string.sub(tostring(i),-6,-1) == "header" then
 
             retval:addHeader(v)
    local entries = {}
         elseif string.sub(tostring(i),-3,-1) == "row" then
 
             retval:addRow(string.sub(tostring(i),1,#tostring(i)-3), v)
     for i, v in pairs(args) do
         local key = tostring(i)
 
        if key:sub(-6) == "header" then
             table.insert(entries, {
                key = key,
                value = v,
                type = "header"
            })
         elseif key:sub(-3) == "row" then
             table.insert(entries, {
                key = key,
                value = v,
                type = "row"
            })
         end
         end
     end
     end
return retval
 
    table.sort(entries, function(a, b)
        local anum = tonumber(a.key:match("^(%d+)")) or math.huge
        local bnum = tonumber(b.key:match("^(%d+)")) or math.huge
 
        if anum ~= bnum then
            return anum < bnum
        end
 
        return a.key < b.key
    end)
 
    for _, entry in ipairs(entries) do
        if entry.type == "header" then
            retval:addHeader(entry.value)
        else
            local label = entry.key:sub(1,-4)
            retval:addRow(label, entry.value)
        end
    end
 
    return retval
end
end


return p
return p

Revision as of 14:56, 2 November 2026

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


local capiunto = require 'capiunto'

local p = {}

function p.main(frame)
    local args = frame:getParent().args

    local headerStyle
    if args.headerstyle and args.headerstyle ~= '' then
        headerStyle = string.format('background-color:%s;', args.headerstyle)
    else
        headerStyle = 'background-color:#a1dbff;'
    end

    local retval = capiunto.create({
        title = args.title,
        headerStyle = headerStyle,
    }):addImage(args.image, args.caption)

    local entries = {}

    for i, v in pairs(args) do
        local key = tostring(i)

        if key:sub(-6) == "header" then
            table.insert(entries, {
                key = key,
                value = v,
                type = "header"
            })
        elseif key:sub(-3) == "row" then
            table.insert(entries, {
                key = key,
                value = v,
                type = "row"
            })
        end
    end

    table.sort(entries, function(a, b)
        local anum = tonumber(a.key:match("^(%d+)")) or math.huge
        local bnum = tonumber(b.key:match("^(%d+)")) or math.huge

        if anum ~= bnum then
            return anum < bnum
        end

        return a.key < b.key
    end)

    for _, entry in ipairs(entries) do
        if entry.type == "header" then
            retval:addHeader(entry.value)
        else
            local label = entry.key:sub(1,-4)
            retval:addRow(label, entry.value)
        end
    end

    return retval
end

return p