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

提供:Azipedia
ナビゲーションに移動 検索に移動
(ページの作成:「local p = {} local g = require("Module:FTBCommon") local box = require("Module:Infobox") -- returns MW code for a block/item infobox function p.main(frame) local frame, args = g.getFrameAndArgs(frame) local usesdeprecated = false -- Arguments for parent infobox -- if g.isGiven(args.name) then -- elseif g.isGiven(args.Rname) then args.name = args.Rname args.Rname = nil usesdeprecated = true else args.name = nil -- let Module:Infobox get the name…」)
 
編集の要約なし
84行目: 84行目:
table.insert(idnames, "<div style=\"word-break: break-all;\">" .. match .. "</div>")
table.insert(idnames, "<div style=\"word-break: break-all;\">" .. match .. "</div>")
end
end
l = l .. box.row("ID Name" .. (#idnames > 1 and "s" or ""), table.concat(idnames, ""))
l = l .. box.row("ID" .. (#idnames > 1 and "s" or ""), table.concat(idnames, ""))
else
else
l = l .. box.row("ID Name", "Unknown")
l = l .. box.row("ID", "不明")
end
end
if g.isGiven(args.oredict) then
--if g.isGiven(args.oredict) then
local odnames = {}
-- local odnames = {}
for match in args.oredict:gmatch("[^;]+") do
-- for match in args.oredict:gmatch("[^;]+") do
table.insert(odnames, "<div style=\"word-break: break-all;\">[[Ore Dictionary name::" .. match .. "]]</div>")
-- table.insert(odnames, "<div style=\"word-break: break-all;\">[[Ore Dictionary name::" .. match .. "]]</div>")
end
-- end
l = l .. box.row("[[OreDict]] Name" .. (#odnames > 1 and "s" or ""), table.concat(odnames, ""))
-- l = l .. box.row("[[OreDict]] Name" .. (#odnames > 1 and "s" or ""), table.concat(odnames, ""))
end
--end
l = l .. box.condRow("First Appearance", args.first)
--l = l .. box.condRow("First Appearance", args.first)
l = l .. box.condRow("Type", args.type)
l = l .. box.condRow("種類", args.type)
if g.isGiven(args.stack) then
if g.isGiven(args.stack) then
if tonumber(args.stack) then
if tonumber(args.stack) then
if tonumber(args.stack) > 1 then
if tonumber(args.stack) > 1 then
l = l .. box.row("Stackable", "Yes (" .. args.stack .. ")")
l = l .. box.row("スタック", "可能 (" .. args.stack .. ")")
else
else
l = l .. box.row("Stackable", "No")
l = l .. box.row("スタック", "不可")
end
end
else
else
l = l .. box.row("Stackable", args.stack)
l = l .. box.row("スタック", args.stack)
end
end
else
else
l = l .. box.row("Stackable", "Unknown")
l = l .. box.row("スタック", "不明")
end
end
118行目: 118行目:
usesdeprecated = usesdeprecated or g.isGiven(args.physics)
usesdeprecated = usesdeprecated or g.isGiven(args.physics)
end
end
l = l .. box.condRow("Affected by Gravity", args.gravity)
l = l .. box.condRow("重力の影響を受ける", args.gravity)
if not g.isGiven(args.trans) then
if not g.isGiven(args.trans) then
124行目: 124行目:
usesdeprecated = usesdeprecated or g.isGiven(args.transparency)
usesdeprecated = usesdeprecated or g.isGiven(args.transparency)
end
end
l = l .. box.condRow("Transparent", args.trans)
l = l .. box.condRow("透過", args.trans)
if not g.isGiven(args.light) then
if not g.isGiven(args.light) then
130行目: 130行目:
usesdeprecated = usesdeprecated or g.isGiven(args.luminance)
usesdeprecated = usesdeprecated or g.isGiven(args.luminance)
end
end
l = l .. box.condRow("Luminance", args.light)
l = l .. box.condRow("明るさ", args.light)
l = l .. box.condRow("Blast Resistance", args.blast)
l = l .. box.condRow("爆発耐性", args.blast)
l = l .. box.condRow("Hardness", args.hardness)
l = l .. box.condRow("硬度", args.hardness)
if g.isGiven(args.fuel) then
if g.isGiven(args.fuel) then
157行目: 157行目:
end
end
l = l .. box.condRow("Fire Resistant", args.fireresistant)
l = l .. box.condRow("耐火", args.fireresistant)
l = l .. box.condRow("Storage", args.storage)
l = l .. box.condRow("Storage", args.storage)
l = l .. box.condRow("Maximum Input Voltage", args.voltin)
l = l .. box.condRow("Maximum Output Voltage", args.voltout)
l = l .. box.condRow("Capacity", args.capacity)
l = l .. box.condRow("Usage Cost", args.usagecost)
l = l .. box.condRow("Power", args.power)
l = l .. box.condRow("Energy", args.energy)
l = l .. box.condRow("Steam Consumption", args.steam)
l = l .. box.condRow("Steam Capacity", args.steamcap)
l = l .. box.condRow("Steam Production", args.steampro)
l = l .. box.condRow("[[EMC|EMC Value]]", args.emc)
l = l .. box.condRow("Formula", args.formula)
l = l .. box.condRow("Formula", args.formula)
186行目: 176行目:
end
end
if g.isGiven(args.fuel) then
if g.isGiven(args.fuel) then
l = l .. "[[Category:Fuel]]"
l = l .. "[[Category:燃料]]"
end
end

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

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

local p = {}

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

-- returns MW code for a block/item infobox
function p.main(frame)
	local frame, args = g.getFrameAndArgs(frame)
	local usesdeprecated = false
	
	-- Arguments for parent infobox --
	
	if g.isGiven(args.name) then
		--
	elseif g.isGiven(args.Rname) then
		args.name = args.Rname
		args.Rname = nil
		usesdeprecated = true
	else
		args.name = nil -- let Module:Infobox get the name
	end
	
	if g.isGiven(args.image) then
		args.fullimage = args.image
		args.image = nil
		usesdeprecated = true
	end
	
	if not g.isGiven(args.img) and not g.isGiven(args.image) then
		args.img = frame:expandTemplate{title="itemimage"}
	end
	
	if g.isGiven(args.imgwidth) then
		--
	elseif g.isGiven(args.imagesize) then
		args.imgwidth = args.imagesize
		args.imagesize = nil
		usesdeprecated = true
	elseif mw.title.new("File:Block " .. tostring(mw.title.getCurrentTitle()) .. ".png").exists then
		args.imgwidth = "128px"
	else
		args.imgwidth = "64px"
	end
	args.imgwidth = g.px(args.imgwidth)
	
	local gridimg
	local gridprop = ""
	if args.gridimg == "nil" then
		gridimg = nil
	else
		if g.isGiven(args.gridimg) then
			gridimg = args.gridimg
		elseif g.isGiven(args.gridimage) then
			gridimg = args.gridimage
			usesdeprecated = true
		else
			gridimg = "Grid " .. tostring(mw.title.getCurrentTitle()) .. ".png"
		end
		
		if g.isGiven(gridimg) then
			gridprop = g.smwProp("Has grid image", gridimg, " ")
		end
		gridimg = gridprop .. frame:expandTemplate{title="GridBox", args={image=gridimg, alt=args.name}}
	end
	
	if g.isGiven(gridimg) then
		if g.isGiven(args.caption) then
			args.caption = gridimg .. "<br/>" .. args.caption
		else
			args.caption = gridimg
		end
	end
	args.gridimg = "nil"
	
	-- New row construction --
	
	local l = ""
	
	l = l .. box.condRow("Tooltip", args.tooltip)
	
	if g.isGiven(args.idname) then
		local idnames = {}
		for match in args.idname:gmatch("[^;]+") do
			table.insert(idnames, "<div style=\"word-break: break-all;\">" .. match .. "</div>")
		end
		l = l .. box.row("ID" .. (#idnames > 1 and "s" or ""), table.concat(idnames, ""))
	else
		l = l .. box.row("ID", "不明")
	end
	
	--if g.isGiven(args.oredict) then
	--	local odnames = {}
	--	for match in args.oredict:gmatch("[^;]+") do
	--		table.insert(odnames, "<div style=\"word-break: break-all;\">[[Ore Dictionary name::" .. match .. "]]</div>")
	--	end
	--	l = l .. box.row("[[OreDict]] Name" .. (#odnames > 1 and "s" or ""), table.concat(odnames, ""))
	--end
	
	--l = l .. box.condRow("First Appearance", args.first)
	l = l .. box.condRow("種類", args.type)
	
	if g.isGiven(args.stack) then
		if tonumber(args.stack) then
			if tonumber(args.stack) > 1 then
				l = l .. box.row("スタック", "可能 (" .. args.stack .. ")")
			else
				l = l .. box.row("スタック", "不可")
			end
		else
			l = l .. box.row("スタック", args.stack)
		end
	else
		l = l .. box.row("スタック", "不明")
	end
	
	if not g.isGiven(args.gravity) then
		args.gravity = args.physics
		usesdeprecated = usesdeprecated or g.isGiven(args.physics)
	end
	l = l .. box.condRow("重力の影響を受ける", args.gravity)
	
	if not g.isGiven(args.trans) then
		args.trans = args.transparency
		usesdeprecated = usesdeprecated or g.isGiven(args.transparency)
	end
	l = l .. box.condRow("透過", args.trans)
	
	if not g.isGiven(args.light) then
		args.light = args.luminance
		usesdeprecated = usesdeprecated or g.isGiven(args.luminance)
	end
	l = l .. box.condRow("明るさ", args.light)
	
	l = l .. box.condRow("爆発耐性", args.blast)
	l = l .. box.condRow("硬度", args.hardness)
	
	if g.isGiven(args.fuel) then
		if g.isGiven(args.fuel2) then
			l = l .. box.row("Burn Time", args.fuel .. " ticks" .. args.fuel2)
		else
			if (args.fuel == 200) then
				l = l .. box.row("Burn Time", args.fuel .. " ticks (" .. (args.fuel / 200) .. " Item)")
			else
				l = l .. box.row("Burn Time", args.fuel .. " ticks (" .. (args.fuel / 200) .. " Items)")
			end
		end
	end
	
	if g.isGiven(args.tool) then
		args.tool = frame:expandTemplate{title="ToolImage", args={args.tool}}
		if g.isGiven(args.tool2) then
			args.tool2 = frame:expandTemplate{title="ToolImage", args={args.tool2}}
			l = l .. box.row("Tool", args.tool .. " " .. args.tool2)
		else
			l = l .. box.row("Tool", args.tool)
		end
	end
	
	l = l .. box.condRow("耐火", args.fireresistant)
	l = l .. box.condRow("Storage", args.storage)
	l = l .. box.condRow("Formula", args.formula)
	
	if g.isGiven(args.rows) then
		l = l .. args.rows
	end
	
	for i = 1, 3 do
		if g.isGiven(args["extra" .. i]) or g.isGiven(args["extrainfo" .. i]) then
			l = l .. box.row(args["extra" .. i], args["extrainfo" .. i])
			usesdeprecated = true
		end
	end
	
	if usesdeprecated then
		l = l .. "[[Category:Infoboxes with deprecated params]]"
	end
	if g.isGiven(args.fuel) then
		l = l .. "[[Category:燃料]]"
	end
	
	args.rows = l
	frame.args = args
	
	return box.main(frame)
end

return p