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 5: Line 4:


function p.main(frame)
function p.main(frame)
    local args = frame:getParent().args
local args = frame:getParent().args
 
local headerStyle
    local headerStyle
if args.headerstyle and args.headerstyle ~= '' then
    if args.headerstyle and args.headerstyle ~= '' then
headerStyle = string.format('background-color:%s;', args.headerstyle)
        headerStyle = string.format('background-color:%s;', args.headerstyle)
else
    else
headerStyle = 'background-color:grey;'
        headerStyle = 'background-color:#a1dbff;'
end
    end
local retval = capiunto.create( {
 
title = args.title,
    local retval = capiunto.create({
headerStyle = headerStyle,
        title = args.title,
} )
        headerStyle = headerStyle,
:addImage( args.image, args.caption )
    }):addImage(args.image, args.caption)
     for i,v in pairs(args) do
 
         if string.sub(i,#tostring(i)-6,#tostring(i)-6) == "header" then
    local entries = {}
             retval:addHeader(v)
 
         elseif string.sub(i,#tostring(i)-3,#tostring(i)-3) == "row" then
     for i, v in pairs(args) do
             retval:addRow( 'Account Made', v)
         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:58, 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:grey;'
	end
	local retval = capiunto.create( {
		title = args.title,
		headerStyle = headerStyle,
	} )
	:addImage( args.image, args.caption )
    for i,v in pairs(args) do
        if string.sub(i,#tostring(i)-6,#tostring(i)-6) == "header" then
            retval:addHeader(v)
        elseif string.sub(i,#tostring(i)-3,#tostring(i)-3) == "row" then
            retval:addRow( 'Account Made', v)
        end
    end
	return retval
end

return p