Module:Item Usage: Difference between revisions
No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 127: | Line 127: | ||
end | end | ||
-- Multiple kitchenware | -- Multiple kitchenware: | ||
-- |kitchenware_1 = | -- |kitchenware_1 = | ||
-- |kitchenware_2 = | -- |kitchenware_2 = | ||
| Line 267: | Line 267: | ||
return nil | return nil | ||
end | |||
local function renderCookingIngredients(recipe) | |||
local ingredients = {} | |||
local maxIndex = getMaxCookingItemIndex(recipe) | |||
for index = 1, maxIndex do | |||
local rendered = renderCookingIngredient(recipe, index) | |||
if isNotEmpty(rendered) then | |||
table.insert(ingredients, rendered) | |||
end | |||
end | |||
return ingredients | |||
end | end | ||
| Line 284: | Line 299: | ||
end | end | ||
return kitchenware | |||
return | |||
end | end | ||
local function | local function renderRecipeIngredients(recipe) | ||
if isCookingRecipe(recipe) then | |||
return renderCookingIngredients(recipe) | |||
end | end | ||
return renderStandardIngredients(recipe) | |||
end | end | ||
local function | local function hasCookingRecipes(valids) | ||
for _, recipes in pairs(valids) do | |||
for _, recipe in pairs(recipes) do | |||
if isCookingRecipe(recipe) then | |||
return true | |||
end | |||
end | |||
end | end | ||
return | return false | ||
end | end | ||
| Line 398: | Line 400: | ||
function p._main(valids, craftType) | function p._main(valids, craftType) | ||
local _table = mw.html.create('table'):addClass('wikitable article-table sortable') | local _table = mw.html.create('table'):addClass('wikitable article-table sortable') | ||
local showKitchenware = hasCookingRecipes(valids) | |||
-- Header row | -- Header row | ||
| Line 403: | Line 406: | ||
tr:tag('th'):wikitext('Item') | tr:tag('th'):wikitext('Item') | ||
tr:tag('th'):wikitext('Craft Type') | tr:tag('th'):wikitext('Craft Type') | ||
if showKitchenware then | |||
tr:tag('th'):wikitext('Kitchenware') | |||
end | |||
tr:tag('th'):wikitext(craftType == 'Furnishing Set' and 'Components' or 'Recipe') | tr:tag('th'):wikitext(craftType == 'Furnishing Set' and 'Components' or 'Recipe') | ||
| Line 443: | Line 451: | ||
:css{['text-align'] = 'center'} | :css{['text-align'] = 'center'} | ||
:wikitext('[[', recipe[Rlib.sTypeArg], ']]') | :wikitext('[[', recipe[Rlib.sTypeArg], ']]') | ||
if showKitchenware then | |||
if isCookingRecipe(recipe) then | |||
local kitchenware = renderCookingKitchenware(recipe) | |||
tr:tag('td'):wikitext(table.concat(kitchenware, '<br>')) | |||
else | |||
tr:tag('td'):wikitext('—') | |||
end | |||
end | |||
local ingredients = renderRecipeIngredients(recipe) | local ingredients = renderRecipeIngredients(recipe) | ||