Difference between revisions of "Module:Bundles"
Jump to navigation
Jump to search
| Line 11: | Line 11: | ||
for k, v in ipairs(currentRow) do | for k, v in ipairs(currentRow) do | ||
vs = mw.text.split(v, '-') | vs = mw.text.split(v, '-') | ||
object = mw.html.create('span') | object = mw.html.create('span') | ||
:wikitext(icon.icon(vs[1], vs[2], nil, 'no')) | :wikitext(icon.icon(vs[1], vs[2], nil, 'no')) | ||
| Line 21: | Line 21: | ||
end | end | ||
table.insert(rowGroup, k, object) | table.insert(rowGroup, k, object) | ||
mw.log(rowGroup[k]) | |||
end | end | ||
result:wikitext(tostring(rowGroup)) | result:wikitext(tostring(rowGroup)) | ||
Revision as of 19:50, 24 October 2021
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)
rowGroup = {}
for k, v in ipairs(currentRow) do
vs = mw.text.split(v, '-')
object = mw.html.create('span')
:wikitext(icon.icon(vs[1], vs[2], nil, 'no'))
if k ~= objects then
object:tag('span')
:addClass('bundle-joiner')
:wikitext('+')
end
table.insert(rowGroup, k, object)
mw.log(rowGroup[k])
end
result:wikitext(tostring(rowGroup))
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(' > ')
end
end
return result
end
function p.bundles(frame)
return bundleGroup(frame.args[1])
end
return p