24,486 ARTICLES
ON THIS WIKI

Module:Infobox/InvItem

< Module:Infobox

Module:Infobox/InvItem
Module:Infobox/InvItem

Name Module:Infobox/InvItem
Tooltip Floating Block of Sand (You Are So Magical)
Source Mod Minecraft
ID Names
awesome:sand
awesome:gravel
OreDict Names
First Appearance Minecraft 1.2.3
Type Awesome Thing
Stackable Yes (42)
Affected by Gravity Why not?
Transparent No idea.
Luminance 24
Blast Resistance 1337
Tool Wooden Pickaxe Imprinter
Fire Resistant True
Storage Whatever
Maximum Input Voltage Input Voltage
Maximum Output Voltage Output Voltage
Capacity Capcacity
Power Power
Energy Energy
Steam Consumption Steam
Steam Capacity SteamCap
Steam Production SteamPro
EMC Value 1234
Formula SiO2
Lua Logo.svg This is the Lua module for Template:Infobox/InvItem. Below is the documentation for that template.

Parameters[edit]

  • name (Old names: Rname, title): Block/item and infobox title. Should be used if actual name differs from page title, for example when the page title contains a disambiguation suffix. Default: {{PAGENAME}}.
  • img: Large block/item image (without File: or square brackets). Replaces {{{image}}}. Default: {{itemimage|{{PAGENAME}}}}
  • imgwidth: Width of the image. Ignored if {{{img}}} is used. Default: 250px.
  • image: Deprecated. Modpack image with full syntax, including File: and square brackets. Replaced by {{{img}}} and {{{imgwidth}}}.
  • gridimg (Old name: gridimage): Small grid image between large image and caption. If a semicolon-separated list of image names is given, they will appear as a cycling animation. The value of this parameter is directly passed to {{GridBox}}, unless nil is passed, in which case the grid box will be hidden.
  • caption: Caption that appears under both. May also be displayed if no image is present. Default: Hidden.
  • tooltip: The block/item's extra tooltip ("lore") text, visible when hovered over in the inventory screen. Default: Hidden.
  • idname: The block/item's ID name, including the mod prefix (e. g. minecraft:sand). If this block/item carries a specific metadata ("damage") value, it should be added after the name, separated by a colon (e. g. minecraft:sand:1). Multiple ID names may be listed by separating them with semicolons. Default: Unknown.
  • oredict: The block/item's Ore Dictionary name. Multiple names may be listed by separating them with semicolons. Default: Hidden.
  • mod: The mod that includes this block/item. If multiple mods provide an item and all implementations are equivalent gameplay-wise, multiple mods may be listed. Items used by a large number of mods may also set this parameter to Various. Default: Unknown.
  • first: When the block/item was first added to the mod. This should ideally include both the mod and Minecraft version.
  • type: The block/item's general type (Tool, Building Block, Machine, Material, Ingot, ...). If the item doesn't fit well into any category, Block or Item should be used. Default: Hidden.
  • stack: The block/item's maximum stack size. This should be a number and will receive additional formatting if it is, though other text is also accepted for backwards compatibility. Default: Unknown.
  • gravity (Old name: physics): Whether the block starts to fall if there is no block under it, like Sand. Default: Hidden.
  • trans (Old name: transparency): Whether the block is technically transparent (i. e. lets light pass), like air or Glass. Default: Hidden.
  • light (Old name: luminance): Whether the block emits light, like Torches or Glowstone. Default: Hidden.
  • blast: The block's blast resistance value. Default: Hidden.
  • hardness: The block's hardness value. Default: Hidden.
  • fuel: The burn time in ticks if the item is a Furnace compatible fuel. Default: Hidden.
  • tool, tool2: The tool required to successfully mine the block. A second tool may be given if two different tool types may be used equally. These should be the lowest level required of the respective tool type, e. g. Wooden Pickaxe for Stone or Diamond Pickaxe for Obsidian. Higher tiers of the same tool or modded multi-type tools (such as the Mining Drill) need not be listed explicitly. Default: Hidden.
  • fireresistant: Whether the item will be destroyed when thrown into Fire or Lava. Default: Hidden
  • storage, voltin, voltout, capacity, power, energy, steam, steamcap, steampro: Various mod-specific fields, their names should be self-explanatory. Default: Hidden.
  • emc: The block/item's EMC value. This should contain the value given by Equivalent Exchange 2 in Minecraft 1.2.5 and ProjectE in new Minecraft versions. While this information is mainly historical, there is little use in listing the values given by Equivalent Exchange 3, as they are not yet used for anything and are subject to change. Default: Hidden.
  • formula: Chemical compound or element added by the MineChem mod formula.
  • rows: Additional info rows besides the default ones. Consists of multiple {{Infobox/Row}}s, separated by single line breaks. Default: Hidden.
  • extra1, extra2, extra3: Deprecated. Titles for three extra info rows. {{{rows}}} should be used instead. Default: Hidden (each row is treated separately).
  • extrainfo1, extrainfo2, extrainfo3: Deprecated. Info for three extra info rows. {{{rows}}} should be used instead. Default: Hidden, respective info title will be centered instead (each row is treated separately).

local p = {}

local g = require("Module:Common")
local box = require("Module:Infobox")
local modnames = require("Module:ModNames")

-- 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.mod) then
		l = l .. box.row("Source Mod", modnames.getWikilink(args.mod, "Is from mod"))
	else
		l = l .. box.row("Source Mod", "Unknown")
	end
	
	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 Name" .. (#idnames > 1 and "s" or ""), table.concat(idnames, ""))
	else
		l = l .. box.row("ID Name", "Unknown")
	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("Type", args.type)
	
	if g.isGiven(args.stack) then
		if tonumber(args.stack) then
			if tonumber(args.stack) > 1 then
				l = l .. box.row("Stackable", "Yes (" .. args.stack .. ")")
			else
				l = l .. box.row("Stackable", "No")
			end
		else
			l = l .. box.row("Stackable", args.stack)
		end
	else
		l = l .. box.row("Stackable", "Unknown")
	end
	
	if not g.isGiven(args.gravity) then
		args.gravity = args.physics
		usesdeprecated = usesdeprecated or g.isGiven(args.physics)
	end
	l = l .. box.condRow("Affected by Gravity", 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("Transparent", 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("Luminance", args.light)
	
	l = l .. box.condRow("Blast Resistance", args.blast)
	l = l .. box.condRow("Hardness", 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("Fire Resistant", args.fireresistant)
	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)
	
	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:Fuel]]"
	end
	
	args.rows = l
	frame.args = args
	
	return box.main(frame)
end

return p