Documentation for this module may be created at Module:Infobox/InvItem/doc
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 = tostring(mw.title.getCurrentTitle())
end
if not g.isGiven(args.img) 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
local gridimg
if args.gridimg == "none" 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
gridimg = 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 = ""
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
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)
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("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("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 Value", args.emc)
if g.isGiven(args.rows) then
l = l .. args.rows .. "\n"
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
args.rows = l
return box.infobox(args)
end
return p