Module:Conflict: Difference between revisions

From roblox chads wiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:


local p = {}
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)
function p.main(frame)
Line 9: Line 17:
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:#9accff;'
end
end
local retval = capiunto.create( {
local retval = capiunto.create( {
Line 16: Line 24:
} )
} )
:addImage( args.image, args.caption )
:addImage( args.image, args.caption )
     :addHeader("Combatants")
     local entries = {}
     :addWikitext([[
    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:addRow(v.context,v.content)
end
end
    retval:addHeader("Combatants")
     retval:addWikitext([[
     <tr>
     <tr>
         <td style="text-align:center; width:50%;">
         <td style="width:50%; text-align:left; border-right:1px solid #bfbfbf;">
             <b>Side 1</b><br />
             <div style="font-weight:bold; margin-bottom:2px;">Side 1</div>
             ]] .. (args.side1 or '') .. [[
             ]]..(args.side1 or '')..[[
         </td>
         </td>
         <td style="text-align:center; width:50%;">
         <td style="width:50%; text-align:left;">
             <b>Side 2</b><br />
             <div style="font-weight:bold; margin-bottom:2px;">Side 2</div>
             ]] .. (args.side2 or '') .. [[
             ]]..(args.side2 or '')..[[
         </td>
         </td>
     </tr>
     </tr>
]])
    ]])
return retval
return retval
end
end


return p
return p

Latest revision as of 22:48, 2 November 2026

Documentation for this module may be created at Module:Conflict/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:#9accff;'
	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:addRow(v.context,v.content)
		end
	end
    retval:addHeader("Combatants")
    retval:addWikitext([[
    <tr>
        <td style="width:50%; text-align:left; border-right:1px solid #bfbfbf;">
            <div style="font-weight:bold; margin-bottom:2px;">Side 1</div>
            ]]..(args.side1 or '')..[[
        </td>
        <td style="width:50%; text-align:left;">
            <div style="font-weight:bold; margin-bottom:2px;">Side 2</div>
            ]]..(args.side2 or '')..[[
        </td>
    </tr>
    ]])
	return retval
end

return p