モジュール:Infobox/Block

提供:Azipedia
ナビゲーションに移動 検索に移動

このモジュールについての説明文ページを モジュール:Infobox/Block/doc に作成できます

local p = {}

local g = require("Module:FTBCommon")
local box = require("Module:Infobox")
local invItem = require("Module:Infobox/InvItem")

-- returns MW code for a block (NOT item) infobox
function p.main(frame)
	local frame, args = g.getFrameAndArgs(frame)
	
	if not g.isGiven(args.type) then args.type = "ブロック" end
	
	local l = ""
	
	l = l .. box.condRow("固体", args.solid, "はい")
	l = l .. box.condRow("透過", args.trans, "しない")
	l = l .. box.condRow("重力の影響", args.gravity, "受けない")
	
	if g.isGiven(args.light) then
		local nlight = tonumber(args.light)
		if nlight == nil then
			l = l .. box.row("発光", args.light)
		elseif nlight <= 0 then
			l = l .. box.row("発光", "しない")
		else
			l = l .. box.row("発光", "する (" .. tostring(nlight) .. ")")
		end
	else
		l = l .. box.row("発光", "しない")
	end
	
	l = l .. box.condRow("可燃性", args.flammable, "なし")
	
	if g.isGiven(args.drops) then
		l = l .. box.row("ドロップするアイテム", args.drops)
	end
	
	if g.isGiven(args.tool) then
		local tools = {}
		for tool in string.gmatch(args.tool, "[^;]+") do
			table.insert(tools, frame:expandTemplate{title="ToolImage", args={tool}})
		end
		l = l .. box.row("必要なツール", table.concat(tools, " "))
	else
		l = l .. box.row("必要なツール", "不明")
	end
	
	-- Need to clear these args so that Infobox/InvItem doesn't handle them again
	args.trans, args.gravity, args.light, args.tool, args.tool2 = nil, nil, nil, nil, nil
	
	if g.isGiven(args.rows) then
		l = l .. args.rows
	end
	
	args.rows = l
	
	frame.args = args
	return invItem.main(frame)
end

return p