Module:Materials row

local p = {}

function p.properties( frame ) local args = frame if frame == mw.getCurrentFrame then args = frame:getParent.args else frame = mw.getCurrentFrame end local grid = require( 'Module:Grid' ) local output = { '|-' }

table.insert( output, '| ' .. args.name )

if args.rgb then table.insert( output, '| style="background-color: rgb(' .. args.rgb .. ');" |  ' ) table.insert( output, '| ' .. args.rgb ) else table.insert( output, '|  ' ) table.insert( output, '| None' ) end

local bools = { liquid = '0', solid = '1', blocklight = '1', blockmove = '1', tool = '0', nodrop = '0', burn = '0', replace = '0', adventureExempt = '0', }

-- Material subclasses if args.subclass == 'liquid' then bools.liquid = '1' bools.blockmove = '0' bools.solid = '0' bools.replace = '1' args.piston = args.piston or 'replace' bools.nodrop = '1' elseif args.subclass == 'nonsolid' then -- MCP "MaterialLogic" bools.solid = '0' bools.blocklight = '0' bools.blockmove = '0' bools.adventureExempt = '1' elseif args.subclass == 'portal' then bools.solid = '0' bools.blocklight = '0' bools.blockmove = '0' bools.nodrop = '1' elseif args.subclass == 'transparent' then bools.solid = '0' bools.blocklight = '0' bools.blockmove = '0' bools.replace = '1' elseif args.subclass == 'cobweb' then bools.blockmove = '0' end

-- Apply args for _, bool in pairs{ 'opaque', 'tool', 'burn', 'replace', 'adventureExempt', 'nodrop' } do       if args[bool] then bools[bool] = args[bool] end end

-- opaque's default is weird bools.opaque = bools.opaque or bools.blockmove

-- Output! local yes = frame:expandTemplate{ title = 'tc', args = { 'yes' } } local no = frame:expandTemplate{ title = 'tc', args = { 'no' } } for _, bool in pairs{ 'liquid', 'solid', 'blocklight', 'blockmove', 'opaque', 'burn', 'replace' } do       if bools[bool] == '0' then table.insert( output, '| ' .. no ) else table.insert( output, '| ' .. yes ) end end

if bools.nodrop == '1' then table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'unknown',           ' ' .. ( bools.tool == '1' and 'Yes' or 'No') .. ' ' } } ..            frame:extensionTag{ name = 'ref', args = { name = 'nodrop', group = 'note' } } ) elseif bools.tool == '1' then table.insert( output, '| ' .. yes ) else table.insert( output, '| ' .. no ) end

args.piston = args.piston or 'pushed' if args.piston == 'pushed' then table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'yes', 'Pushed' } } ) elseif args.piston == 'replace' then table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'neutral', 'Replace' } } ) elseif args.piston == 'blocked' then table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'no', 'Blocked' } } ) else table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'unknown', args.piston } } ) end

return table.concat( output, '\n' ) end

function p.blocks( frame ) local args = frame if frame == mw.getCurrentFrame then args = frame:getParent.args else frame = mw.getCurrentFrame end local grid = require( 'Module:Grid' ) local output = { '|-' }

table.insert( output, '| ' .. args.name )

if args.blocks or  ~=  then local images = {} for block in mw.text.gsplit( args.blocks, '%s*,%s*' ) do			table.insert( images, grid.cell{ block, class = 'plain' } ) end table.insert( output, '| style="text-align:center" | ' .. table.concat( images ) ) else table.insert( output, '| ' ) end

table.insert( output, '| ' .. ( args.note or '' ) )

return table.concat( output, '\n' ) end

return p