Module:Schematic

local p = {} function p.table( f ) local args = f.args if args[1] == nil then args = f:getParent.args end local caption = args.caption or '' local captionstyle = args.captionstyle or '' local clear = args.clear or '' local float = args.float or '' local size = tonumber( args.size ) or 32 local style = args.style or '' local tablestyle = args.tablestyle or '' local sprite = require( 'Module:Sprite' ).base local ids = mw.loadData( 'Module:Sprite/Schematic' ) local titles = mw.loadData( 'Module:Schematic/Titles' ) local isTable = false if args[2] or  ~=  then isTable = true end if size ~= 32 then tablestyle = 'font-size:' .. size .. 'px;' .. tablestyle end local cols = 0 local maxcols = 0 local schematic = {} local title = '' for _, cell in ipairs( args ) do		cell = mw.text.trim( cell ) if cell == '' then if isTable then table.insert( schematic, '|' ) else table.insert( schematic, ' ' ) end elseif isTable and cell == '-' then cols = 0 table.insert( schematic, '|-' ) else cols = cols + 1 if cols > maxcols then maxcols = cols end local layers = {} title = {} for layer in mw.text.gsplit( cell, '%s*+%s*' ) do				layer = mw.text.trim( layer ) if layer ~= '' and layer ~= 'air' then local pos = ids[layer] if pos then table.insert( layers, sprite{							name = 'Schematic',							size = 16,							sheetsize = 512,							pos = pos,							scale = size / 16						} ) if titles[layer] then table.insert( title, 1, titles[layer] ) end else table.insert( layers, ' ' .. layer .. ' ' ) end end end if args.text then table.insert( layers, ' ' .. args.text .. ' ' ) end title = table.concat( title, ' over ' ) layers = table.concat( layers, '' ) if isTable then if layers ~= '' then layers = '| title="' .. title .. '" | ' .. layers .. ' '				else layers = '|' end end table.insert( schematic, layers ) end end local attr = 'class="schematic schematic2" style="' .. tablestyle .. '"' if isTable then table.insert( schematic, 1, ' {|' .. attr ) table.insert( schematic, '|}' ) else table.insert( schematic, 1, ' ' ) table.insert( schematic, ' ' ) end local out if caption ~=  or float ~=  then if float == '' then float = 'right' end if clear == '' then clear = 'none' end local captionwidth = maxcols * ( size + 1 ) + 1 if captionwidth < 182 then captionwidth = 182 end out = { ' ',				' ',					table.concat( schematic, '\n' ), ' ' .. caption .. ' ',				' ',			' '		}		out = table.concat( out, '\n' ) else out = table.concat( schematic, '\n' ) end out = out:gsub( ' style=""',  ):gsub( ' title=""%s*|?',  ) return out end return p