Minecraft Wiki

除另有声明,转载时均必须注明出处若簡繁轉換出錯,請以遊戲內為準请勇于扩充与修正内容有兴趣逛逛我们的微博沟通交流,欢迎到社区专页需要协助,请在告示板留言

了解更多

Minecraft Wiki
Advertisement
[创建 | 历史 | 清除缓存]文档页面
此模块没有文档页面。如果你知道如何使用模块,请创建它。
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 = { '|-' }

    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, '| 无' )
    end

    local bools = {
        liquid = '0',
        solid = '1',
        blockmove = '1',
        tool = '0',
        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', 'tool', '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', 'tool', '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', '推动' } } )
    elseif args.piston == 'replace' then
        table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'neutral', '替换' } } )
    elseif args.piston == 'blocked' then
        table.insert( output, '| ' .. frame:expandTemplate{ title = 'tc', args = { 'no', '阻挡' } } )
    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 = { '|-' }

    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, slot{ block, class = 'invslot-plain' } )
		end
        table.insert( output, '| style="text-align:center" | ' .. table.concat( images ) )
    else
        table.insert( output, "| style=\"text-align:center\" |  ''没有应用到任何方块。''" )
    end

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

return p
Advertisement