Jump to content

Module:Sprite/doc

From SankoQuest Wiki

This is the documentation page for Module:Sprite

This is the documentation page for Module:Sprite.

Renders an item icon from the Sanko item sprite atlas as a CSS background-positioned <span>. Atlas coordinates come from the data module Module:Sprite/Item (loaded via mw.loadData).

Functions

item

The only public function. Called as {{#invoke:Sprite|item|name=...|size=...|link=...}}.

Parameter Meaning Default
name (or first positional) Item name; must match a key in Module:Sprite/Item's items table exactly (trimmed, case-sensitive).
size Rendered icon size in pixels; the atlas is scaled by size / cell (cell is 32). 32
link Page to wikilink the icon to. Empty = no link. none

Output is a span.sanko-sprite with role="img", aria-label, and data-minetip-title set to the item name, plus computed background-position/background-size. When link is set the span is wrapped in span.sanko-sprite-link containing a wikilink.

Used by

Prefer calling these templates from articles rather than #invoke directly, e.g. {{ItemSprite|Air Shard|size=32}}.

Notes and sharp edges

  • The lookup is exact-match on the trimmed name. An unknown name does not error; it renders a span.sanko-sprite-missing placeholder showing ? (minetip "Unknown item" when the name is blank). If an icon shows ?, check spelling/capitalization against Module:Sprite/Item.
  • The module only reads frame.args, not the parent frame's arguments — templates must pass name/size/link through explicitly, as the two templates above do.
  • The module sets background position/size only; the atlas image itself is attached by the .sanko-sprite site CSS, not by this module. The url/image fields in the data module are not read here.
  • Offsets are math.floor-ed after scaling, so sizes that are not multiples of the 32 px cell can be off by up to a pixel.