Jump to: navigation, search

Module:BlockGrid

Revision as of 15:46, 14 February 2014 by MrTJP (talk | contribs) (1 revision)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local p = {}
function p.grid( f )
	local args = f:getParent().args
	local rows = {}
	local sprite = require( 'Module:Sprite' ).link
	local size = 16 * ( args.scale or 1 )
	
	for k, v in ipairs( args ) do
		local row = {}
		for v2 in mw.text.gsplit( v:gsub( '^%s-\n+', '' ):gsub( '\n+%s-$', '' ), '' ) do
			if mw.text.trim( v2 ) == '' or args[v2] == 'air' then
				table.insert( row, ' style="width:' .. size .. 'px;height:' .. size .. 'px" | ' )
			else
				table.insert( row, sprite{ settings = 'BlockSprite', args[v2], '', scale = args.scale } )
			end
		end
		
		table.insert( rows, table.concat( row, ' || ' ) )
	end
	
	return '{| cellspacing="0" cellpadding="0" style="line-height:0"\n| ' .. table.concat( rows, '\n|-\n| ' ) .. '\n|}'
end
return p


Cookies help us deliver our services. By using our services, you agree to our use of cookies.