Module:Materials row
Jump to navigation
Jump to search
p.properties
implements {{Materials row}}
.
p.blocks
implements {{Material blocks row}}
.
See those pages for documentation.
[view] [edit] [history] [refresh]The above documentation is transcluded from Module:Materials row/doc.
local p = {}
function p.properties( frame )
local args = frame
if frame == mw.getCurrentFrame() then
args = frame:getParent().args
else
frame = mw.getCurrentFrame()
end
local output = {}
if args.anchor and args.anchor ~= "" then
table.insert( output, '|- id="' .. args.anchor .. '"' )
else
table.insert( output, '|-' )
end
if args.th and args.th ~= "" then
table.insert( output, '! scope=row | ' .. args.name )
else
table.insert( output, '| ' .. args.name )
end
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',
blockmove = '1',
burn = '0',
replace = '0',
solidBlocking = '1'
}
-- 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'
elseif args.subclass == 'nonsolid' then
bools.solid = '0'
bools.blockmove = '0'
elseif args.subclass == 'transparent' then
bools.solid = '0'
bools.blockmove = '0'
bools.replace = '1'
args.piston = args.piston or 'replace'
end
-- Apply args
for _, bool in pairs{ 'liquid', 'solid', 'blockmove', 'burn', 'replace', 'solidBlocking' } do
if args[bool] then
bools[bool] = args[bool]
end
end
-- Output!
local yes = frame:expandTemplate{ title = 'tc', args = { 'yes' } }
local no = frame:expandTemplate{ title = 'tc', args = { 'no' } }
for _, bool in pairs{ 'liquid', 'solid', 'solidBlocking', 'blockmove', 'burn', 'replace' } do
if bools[bool] == '0' then
table.insert( output, '| ' .. no )
else
table.insert( output, '| ' .. yes )
end
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 slot = require( 'Module:Inventory slot' ).slot
local output = {}
if args.anchor and args.anchor ~= "" then
table.insert( output, '|- id="' .. args.anchor .. '"' )
else
table.insert( output, '|-' )
end
if args.th and args.th ~= "" then
table.insert( output, '! scope=row | ' .. args.name )
else
table.insert( output, '| ' .. args.name )
end
if args.blocks or '' ~= '' then
local images = {}
for block in mw.text.gsplit( args.blocks, '%s*,%s*' ) do
table.insert( images, slot{ block, class = 'invslot-plain' } )
end
table.insert( output, '| style="text-align:center" | ' .. table.concat( images ) )
else
table.insert( output, "| style=\"text-align:center\" | ''Not applied to any blocks.''" )
end
return table.concat( output, '\n' )
end
return p