24,485 ARTICLES
ON THIS WIKI

Module:Infobox/Block

< Module:Infobox

Module:Infobox/Block
Module:Infobox/Block

Name Module:Infobox/Block
Source Mod Unknown
ID Name Unknown
Type Block
Stackable Unknown
Solid No
Transparent Yes
Affected by Gravity Yes
Emits Light Yes (13)
Flammable Yes
Required Tool Wooden Axe Wooden Pickaxe None
Lua Logo.svg This is the Lua module for Template:Infobox/Block. Below is the documentation for that template.

Parameters[edit]

  • All parameters from {{Infobox/InvItem}}
    • type Default: Block.
  • solid: Whether the block is solid, i. e. entities collide with it. Default: Yes.
  • trans: Whether the block is transparent, i. e. light passes through it. Default: No.
  • gravity: Whether the block is affected by gravity, i. e. turns into a falling entity when there is no other block under it. Default: No.
  • light: The amount of light that the block emits. Default: 0.
  • flammable: Whether the block is flammable, i. e. fire will burn on it until it is destroyed. Default: No.
  • drops: A field to list the drops of a block. Default: Hidden.
  • tool: The lowest tier tool required to successfully mine (or otherwise collect) the block. Multiple tools may be listed in special cases by separating their names with semicolons. Default: Unknown.

local p = {}

local g = require("Module:Common")
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("Affected by Gravity", args.gravity, "No")
	
	if g.isGiven(args.light) then
		local nlight = tonumber(args.light)
		if nlight == nil then
			l = l .. box.row("Emits Light", args.light)
		elseif nlight <= 0 then
			l = l .. box.row("Emits Light", "No")
		else
			l = l .. box.row("Emits Light", "Yes (" .. tostring(nlight) .. ")")
		end
	else
		l = l .. box.row("Emits Light", "No")
	end
	
	l = l .. box.condRow("Flammable", args.flammable, "No")
	
	if g.isGiven(args.drops) then
		l = l .. box.row("Drops", 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("Required Tool", table.concat(tools, " "))
	else
		l = l .. box.row("Required Tool", "Unknown")
	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