Module:InventorySlot
Appearance
This is the documentation page for Module:InventorySlot.
Renders a single inventory-style item slot: a span.sanko-inventory-slot containing a 28 px item sprite (via Template:ItemSprite, linked to the item's page) and, when the quantity is anything other than 1, a span.sanko-inventory-qty badge.
Functions
slot
Wikitext entry point: {{#invoke:InventorySlot|slot|item=...|qty=...}}. item and qty may also be given as the first and second positional parameters.
| Parameter | Meaning | Default |
|---|---|---|
item (or first positional) |
Item name; also used as the sprite's link target. Empty renders an empty slot. | — |
qty (or second positional) |
Quantity badge text. Hidden when empty or exactly 1. |
hidden |
Example:
{{#invoke:InventorySlot|slot|Iron Bar|3}}
_slot
Module-to-module entry point: p._slot(frame, item, qty). Takes the same values as plain Lua arguments and returns the rendered HTML string. This is how Module:Recipe draws its input and output slots.
Used by
- Module:Recipe — via
require('Module:InventorySlot')andinventory._slot(frame, item, qty). - No template currently calls
#invoke:InventorySlotdirectly.
Notes and sharp edges
- The sprite is produced with
frame:expandTemplate{ title = 'ItemSprite', ... }, so this module breaks if Template:ItemSprite is renamed or deleted, and the item name must exist in Module:Sprite/Item or the slot shows the missing-sprite?placeholder. - The quantity check is a string comparison: only the exact string
1(or empty) is suppressed. Values like01or1will display. The value is shown verbatim — no number formatting. - Sprite size is fixed at 28 px and the link always targets the item name; neither is parameterized.
local p = {}
local function slot(frame, item, qty)
local root = mw.html.create('span')
:addClass('sanko-inventory-slot')
if item and item ~= '' then
root:wikitext(frame:expandTemplate{ title = 'ItemSprite', args = { item, size = '28', link = item } })
if qty and qty ~= '' and qty ~= '1' then
root:tag('span')
:addClass('sanko-inventory-qty')
:wikitext(qty)
end
end
return tostring(root)
end
function p.slot(frame)
return slot(frame, frame.args.item or frame.args[1], frame.args.qty or frame.args[2])
end
function p._slot(frame, item, qty)
return slot(frame, item, qty)
end
return p