Module:Recipe
This is the documentation page for Module:Recipe.
Renders the visual recipe box (div.sanko-recipe) shown by Template:Recipe: a row of metadata pills, up to six input item slots, an arrow, and an output slot. Item slots are drawn by Module:InventorySlot (required, via _slot).
This module is display-only. The Cargo storage for recipes (a Recipes row, plus RecipeIngredients/RecipeOutputs rows stored via Template:RecipeIngredient and Template:RecipeOutput) is handled by the wikitext of Template:Recipe itself, not here.
Functions
box
Called from Template:Recipe as {{#invoke:Recipe|box}} with no explicit arguments: each parameter is taken from frame.args when present there, otherwise from the parent frame's (i.e. the template call's) arguments; a value that is missing or empty after that lookup falls back to the default. (A parameter set to an empty string in frame.args does not fall through to the parent frame — the parent is only consulted when the key is absent.)
| Parameter | Meaning | Default |
|---|---|---|
recipe_kind |
Pill text; also switches output rendering (see below). | Crafting
|
station, skill, element |
Rendered as pills when non-empty. | omitted |
level_req, xp, base_max_hit |
Rendered as "Level N", "N XP", "Max hit N" pills when non-empty. | omitted |
input1…input6 |
Input item names; each non-empty one becomes an inventory slot. | omitted |
input1_qty…input6_qty |
Quantity for the matching input. | 1
|
output (fallback output_item) |
Output item name. | — |
output_qty |
Output quantity. | 1
|
Used by
- Template:Recipe — the invocation is the last piece of the template, after its
#cargo_storecalls. Articles use the template, e.g. from Air Missile:
{{Recipe
|recipe_id=spell_air_missile
|recipe_kind=Spell
|output=Air Missile
|output_qty=1
|station=Spellbook
|skill=Magic
|level_req=1
|xp=
|element=air
|base_max_hit=2
|source=SankoQuest game data
|verification_status=Needs gameplay verification
|input1=Air Shard
|input1_qty=1
|input2=Spirit Shard
|input2_qty=1
}}
(source and verification_status are consumed by Template:Recipe's Cargo rows, not by this module.)
Notes and sharp edges
- When
recipe_kindis exactlySpell(case-sensitive), the output is rendered as text indiv.sanko-spell-outputinstead of an item slot, with a smallxNsuffix whenoutput_qtyis not1— useful for outputs that are not inventory items. - Only six input slots exist;
input7and beyond are ignored. - The arrow (
→) and the output area render even when inputs or output are empty, so a bare invocation still produces a (mostly empty) box. - Input/output item names must match keys in Module:Sprite/Item or their slots show the missing-sprite
?placeholder.
local inventory = require('Module:InventorySlot')
local p = {}
local function arg(frame, name, fallback)
local parent = frame:getParent()
local parentArgs = parent and parent.args or {}
local value = frame.args[name] or parentArgs[name]
if value == nil or value == '' then
return fallback or ''
end
return value
end
function p.box(frame)
local root = mw.html.create('div')
:addClass('sanko-recipe')
local meta = root:tag('div')
:addClass('sanko-recipe-meta')
local station = arg(frame, 'station')
local skill = arg(frame, 'skill')
local level = arg(frame, 'level_req')
local xp = arg(frame, 'xp')
local recipeKind = arg(frame, 'recipe_kind', 'Crafting')
local element = arg(frame, 'element')
local baseMaxHit = arg(frame, 'base_max_hit')
if recipeKind ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext(recipeKind)
end
if station ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext(station)
end
if skill ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext(skill)
end
if level ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext('Level ' .. level)
end
if xp ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext(xp .. ' XP')
end
if element ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext(element)
end
if baseMaxHit ~= '' then
meta:tag('span'):addClass('sanko-pill'):wikitext('Max hit ' .. baseMaxHit)
end
local body = root:tag('div')
:addClass('sanko-recipe-body')
local inputs = body:tag('div')
:addClass('sanko-recipe-inputs')
for index = 1, 6 do
local item = arg(frame, 'input' .. index)
if item ~= '' then
inputs:wikitext(inventory._slot(frame, item, arg(frame, 'input' .. index .. '_qty', '1')))
end
end
body:tag('div')
:addClass('sanko-recipe-arrow')
:wikitext('→')
local outputItem = arg(frame, 'output', arg(frame, 'output_item'))
local outputQty = arg(frame, 'output_qty', '1')
local output = body:tag('div')
:addClass('sanko-recipe-output')
if recipeKind == 'Spell' then
output:tag('div')
:addClass('sanko-spell-output')
:wikitext(outputItem)
if outputQty ~= '' and outputQty ~= '1' then
output:tag('small'):wikitext('x' .. outputQty)
end
else
output:wikitext(inventory._slot(frame, outputItem, outputQty))
end
return tostring(root)
end
return p