Module:Test: Difference between revisions
From roblox chads wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
| Line 27: | Line 27: | ||
for i,v in pairs(args) do | for i,v in pairs(args) do | ||
if string.sub(tostring(i),1,6) == "header" then | if string.sub(tostring(i),1,6) == "header" then | ||
entries[tonumber(string.sub(tostring | entries[tonumber(string.sub(tostring(i),7,#i))] = { | ||
["type"] = "header", | ["type"] = "header", | ||
["content"] = v, | ["content"] = v, | ||
} | } | ||
elseif string.sub(tostring(i),1,3) == "row" then | elseif string.sub(tostring(i),1,3) == "row" then | ||
entries[tonumber(string.sub(tostring | entries[tonumber(string.sub(tostring(i),4,#split(i,"-")[1]))] = { | ||
["type"] = "row", | ["type"] = "row", | ||
["content"] = v, | ["content"] = v, | ||
Revision as of 16:30, 2 November 2026
Documentation for this module may be created at Module:Test/doc
local capiunto = require 'capiunto'
local p = {}
function split(string,seperate)
local arg = {}
for i in string.gmatch(string,"([^"..seperate.."]+)") do
arg[#arg+1] = i
end
return arg
end
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 )
local entries = {}
for i,v in pairs(args) do
if string.sub(tostring(i),1,6) == "header" then
entries[tonumber(string.sub(tostring(i),7,#i))] = {
["type"] = "header",
["content"] = v,
}
elseif string.sub(tostring(i),1,3) == "row" then
entries[tonumber(string.sub(tostring(i),4,#split(i,"-")[1]))] = {
["type"] = "row",
["content"] = v,
["context"] = string.sub(i,#split(i,"-")[1]+2,#i),
}
end
end
for i,v in pairs(entries) do
if v.type == "header" then
retval:addHeader(v.content)
elseif v.type == "row" then
retval:addHeader(v.context,v.content)
end
end
return retval
end
return p