Module:Products: Difference between revisions

877 bytes added ,  28 December 2024
recipes which have the passive tag will have their quantities displayed as per-hour, rather than per-recipe
("pre-sort by output item" doesnt work because it was sorting by page that had the recipe, instead simply sort by level of the recipe)
(recipes which have the passive tag will have their quantities displayed as per-hour, rather than per-recipe)
 
Line 78:
table.sort(recipes, recipe_sort)
 
-- if recipe is passive, want per hour
for _, recipe in ipairs(recipes) do
recipe.recipePerHour = recipe.duration and math.floor(3600/recipe.duration)
-- replace quantities with per-hour quantities
-- if recipe.passive then
for _,item in ipairs(recipe.output) do
item.displayQuantity = (item.quantity and recipe.recipePerHour and item.quantity * recipe.recipePerHour) or ''
end
for _,item in ipairs(recipe.materials) do
item.displayQuantity = (item.quantity and recipe.recipePerHour and item.quantity * recipe.recipePerHour) or ''
end
-- end
end
-- Calculate shop prices
if showPrices then
Line 128 ⟶ 142:
:css{ ['border-right'] = '0', ['padding-right'] = '0' }
:attr{ ['data-sort-value'] = recipe.output[1].name }
:wikitextIF(recipe.output[1].quantity .. ' ×'passive)
:wikitext(recipe.output[1].displayQuantity .. ' (/hr) ×')
:ELSE()
:wikitext(recipe.output[1].quantity .. ' ×')
:END()
:done()
:tag('td')
Line 167 ⟶ 185:
for _, item in ipairs(recipe.materials) do
ingredients:tag('li')
:IF(recipe.passive)
:wikitext(('%s × [[File:%s.png|link=%s|18px]] [[%s]]'):format(item.quantity, item.name, item.name, item.name))
:wikitext(('%s (/hr) × [[File:%s.png|link=%s|18px]] [[%s]]'):format(item.displayQuantity, item.name, item.name, item.name))
:ELSE()
:wikitext(('%s × [[File:%s.png|link=%s|18px]] [[%s]]'):format(item.quantity, item.name, item.name, item.name))
:END()
:done()
end
19,507

edits