Module:Bundles

From Foundation - Wiki
Revision as of 09:29, 24 October 2021 by Sakaratte (talk | contribs)
Jump to navigation Jump to search

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

local p = {}
local com = require( "Module:Common" )
local icon = require( "Module:Icon" )

function bundleRow(currentRow)
	currentRow = mw.text.split(currentRow, ';')
	objects = table.getn(currentRow)
	result = mw.html.create('div')
	result:addClass('bundle-row bundle-col-' .. objects)
	for k, v in ipairs(currentRow) do
		vs = mw.text.split(v, '-')
		result:tag('span')
			:wikitext(icon._requirements(vs[1], vs[2], nil, 'no'))
			:done()
		if k ~= objects then
			result:tag('span')
			:addClass('bundle-joiner')
			:wikitext('+')
		end
	end
	return result
end

function bundleGroup(bundle)
	bundleRows = mw.text.split(bundle, '\n')
	rowCount = table.getn(bundleRows)
	result = mw.html.create('div')
	result:addClass('bundle-frame')
	for k, v in ipairs(bundleRows) do
		result:node(bundleRow(v))
		if k ~= rowCount then
			result:tag('div')
				:addClass('bundle-movement')
				:wikitext('&nbsp> ')
		end
	end
	return result
end

function p.bundles(frame)
	return bundleGroup(frame.args[1])
end

return p