Module:Products: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
("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: | Line 78: | ||
table.sort(recipes, recipe_sort) |
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 |
-- Calculate shop prices |
||
if showPrices then |
if showPrices then |
||
Line 128: | Line 142: | ||
:css{ ['border-right'] = '0', ['padding-right'] = '0' } |
:css{ ['border-right'] = '0', ['padding-right'] = '0' } |
||
:attr{ ['data-sort-value'] = recipe.output[1].name } |
:attr{ ['data-sort-value'] = recipe.output[1].name } |
||
: |
:IF(recipe.passive) |
||
:wikitext(recipe.output[1].displayQuantity .. ' (/hr) ×') |
|||
:ELSE() |
|||
:wikitext(recipe.output[1].quantity .. ' ×') |
|||
:END() |
|||
:done() |
:done() |
||
:tag('td') |
:tag('td') |
||
Line 167: | Line 185: | ||
for _, item in ipairs(recipe.materials) do |
for _, item in ipairs(recipe.materials) do |
||
ingredients:tag('li') |
ingredients:tag('li') |
||
:IF(recipe.passive) |
|||
⚫ | |||
:wikitext(('%s (/hr) × [[File:%s.png|link=%s|18px]] [[%s]]'):format(item.displayQuantity, item.name, item.name, item.name)) |
|||
:ELSE() |
|||
⚫ | |||
:END() |
|||
:done() |
:done() |
||
end |
end |