「モジュール:Infobox/Block」の版間の差分

提供:Azipedia
ナビゲーションに移動 検索に移動
(ページの作成:「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 = "Block" end local l = "" l = l .. box.condRow("Solid", args.solid, "Yes") l = l .. box.condRow("Transparent", args.trans, "No") l = l .. box.condRow("Affe…」)
 
編集の要約なし
9行目: 9行目:
local frame, args = g.getFrameAndArgs(frame)
local frame, args = g.getFrameAndArgs(frame)
if not g.isGiven(args.type) then args.type = "Block" end
if not g.isGiven(args.type) then args.type = "ブロック" end
local l = ""
local l = ""
l = l .. box.condRow("Solid", args.solid, "Yes")
l = l .. box.condRow("固体", args.solid, "Yes")
l = l .. box.condRow("Transparent", args.trans, "No")
l = l .. box.condRow("透過", args.trans, "No")
l = l .. box.condRow("Affected by Gravity", args.gravity, "No")
l = l .. box.condRow("重力の影響を受ける", args.gravity, "No")
if g.isGiven(args.light) then
if g.isGiven(args.light) then
local nlight = tonumber(args.light)
local nlight = tonumber(args.light)
if nlight == nil then
if nlight == nil then
l = l .. box.row("Emits Light", args.light)
l = l .. box.row("発光", args.light)
elseif nlight <= 0 then
elseif nlight <= 0 then
l = l .. box.row("Emits Light", "No")
l = l .. box.row("発光", "いいえ")
else
else
l = l .. box.row("Emits Light", "Yes (" .. tostring(nlight) .. ")")
l = l .. box.row("発光", "はい (" .. tostring(nlight) .. ")")
end
end
else
else
l = l .. box.row("Emits Light", "No")
l = l .. box.row("発光", "いいえ")
end
end
l = l .. box.condRow("Flammable", args.flammable, "No")
l = l .. box.condRow("可燃性", args.flammable, "いいえ")
if g.isGiven(args.drops) then
if g.isGiven(args.drops) then
l = l .. box.row("Drops", args.drops)
l = l .. box.row("ドロップするアイテム", args.drops)
end
end
41行目: 41行目:
table.insert(tools, frame:expandTemplate{title="ToolImage", args={tool}})
table.insert(tools, frame:expandTemplate{title="ToolImage", args={tool}})
end
end
l = l .. box.row("Required Tool", table.concat(tools, " "))
l = l .. box.row("必要なツール", table.concat(tools, " "))
else
else
l = l .. box.row("Required Tool", "Unknown")
l = l .. box.row("必要なツール", "不明")
end
end

2022年5月22日 (日) 23:03時点における版

このモジュールについての説明文ページを モジュール: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, "Yes")
	l = l .. box.condRow("透過", args.trans, "No")
	l = l .. box.condRow("重力の影響を受ける", args.gravity, "No")
	
	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