Module:Infobox Recipe: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(Add facility to recipe json) |
(when a recipe is set to passive, display the -per-hour p and materials in brackets) |
||
Line 115: | Line 115: | ||
rawMaterials = argsMaterials |
rawMaterials = argsMaterials |
||
end |
end |
||
--If it is a passive recipe, will want to display the per-hour values for XP and materials used |
|||
args.recipePerHour = args.duration and math.floor(3600/args.duration) |
|||
args.displayXP = (tonumber(args.exp) and args.recipePerHour and tonumber(args.exp) * args.recipePerHour) or '' |
|||
args.displayOutput1qty = (args.output1qty and args.recipePerHour and args.output1qty * args.recipePerHour) or '' |
|||
--Simple query to get the shop buy price for the provided material, if no buy price is available returns 0 |
--Simple query to get the shop buy price for the provided material, if no buy price is available returns 0 |
||
Line 147: | Line 153: | ||
local materialBuyPrice = getBuyPrice(item) * (item.quantity or 1) |
local materialBuyPrice = getBuyPrice(item) * (item.quantity or 1) |
||
rawMaterialCost = rawMaterialCost + materialBuyPrice |
rawMaterialCost = rawMaterialCost + materialBuyPrice |
||
local displayQuantity = item.quantity or 1 |
|||
if passive then |
|||
displayQuantity = displayQuantity and args.recipePerHour and displayQuantity * args.recipePerHour |
|||
end |
|||
return mw.html.create('tr') |
return mw.html.create('tr') |
||
:tag('td') |
:tag('td') |
||
Line 159: | Line 169: | ||
:css{ ['text-align'] = 'right' } |
:css{ ['text-align'] = 'right' } |
||
:wikitext(item.quantity or 1) |
:wikitext(item.quantity or 1) |
||
:IF(passive) |
|||
:wikitext('<br>( ' .. displayQuantity .. ' per hour)' ) |
|||
:END() |
|||
:done() |
:done() |
||
:node(currency_cell(materialBuyPrice)) |
:node(currency_cell(materialBuyPrice)) |
||
Line 232: | Line 245: | ||
:wikitext(hc(args.displayXP) and (formatNum(tonumber(args.displayXP))) or ("'''?'''")) |
:wikitext(hc(args.displayXP) and (formatNum(tonumber(args.displayXP))) or ("'''?'''")) |
||
:wikitext(' total)') |
:wikitext(' total)') |
||
:END() |
|||
:IF(passive) |
|||
:wikitext(' (') |
|||
:wikitext(hc(args.displayXP) and (formatNum(tonumber(args.displayXP))) or ("'''?'''")) |
|||
:wikitext(' per hour)') |
|||
:END() |
:END() |
||
:done() |
:done() |
||
Line 385: | Line 403: | ||
:css{ ['text-align'] = 'right' } |
:css{ ['text-align'] = 'right' } |
||
:wikitext(args.output1qty or 1) |
:wikitext(args.output1qty or 1) |
||
:IF(passive) |
|||
:wikitext('<br>( ' .. args.displayOutput1qty .. ' per hour)' ) |
|||
:END() |
|||
:done() |
:done() |
||
:node(currency_cell(output1TotalValue)) |
:node(currency_cell(output1TotalValue)) |