Difference between revisions of "Module:Bundles"
Jump to navigation
Jump to search
(Created page with "local p = {} local com = require( "Module:Common" ) function bundleRow() end function bundleGroup(bundle) bundleRows = mw.text.split(bundle, '\n') for k, v in ipairs(bu...") |
m (18 revisions imported: Importing from localhost) |
||
(17 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local com = require( "Module:Common" ) | local com = require( "Module:Common" ) | ||
local icon = require( "Module:Icon" ) | |||
function bundleRow(currentRow) | |||
currentRow = mw.text.split(currentRow, ';') | |||
objects = table.getn(currentRow) | |||
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')) | |||
rowGroup = rowGroup .. tostring(object) | |||
if k ~= objects then | |||
object = mw.html.create('span') | |||
:addClass('bundle-joiner') | |||
:wikitext(' + ') | |||
rowGroup = rowGroup .. tostring(object) | |||
end | |||
end | |||
result = mw.html.create('div') | |||
result:addClass('bundle-row bundle-col-' .. objects) | |||
result:wikitext(rowGroup) | |||
mw.log(result) | |||
return result | |||
end | end | ||
function bundleGroup(bundle) | function bundleGroup(bundle) | ||
bundleRows = mw.text.split(bundle, '\n') | 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 | for k, v in ipairs(bundleRows) do | ||
result:node(bundleRow(v)) | |||
if k ~= rowCount then | |||
result:tag('div') | |||
:addClass('bundle-movement') | |||
:wikitext(' > ') | |||
end | |||
end | end | ||
return result | |||
end | end | ||
Latest revision as of 14:15, 1 December 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) 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')) rowGroup = rowGroup .. tostring(object) if k ~= objects then object = mw.html.create('span') :addClass('bundle-joiner') :wikitext(' + ') rowGroup = rowGroup .. tostring(object) end end result = mw.html.create('div') result:addClass('bundle-row bundle-col-' .. objects) result:wikitext(rowGroup) mw.log(result) 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