Module:Infobox Recipe: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
No edit summary
(Fix raw material quantity not multiplying price)
Line 1: Line 1:
require('strict')
require('Module:Mw.html extension')
local currency = require('Module:Currency')
local currency = require('Module:Currency')
local hc = require('Module:Param Parse').has_content
local hc = require('Module:Param Parse').has_content
Line 100: Line 102:
--Creates a row suitable for the raw materials section of the infobox.
--Creates a row suitable for the raw materials section of the infobox.
local function createRawMaterialRow(item)
local function createRawMaterialRow(item)
local materialBuyPrice = getBuyPrice(item)
local materialBuyPrice = getBuyPrice(item) * (item.quantity or 1)
rawMaterialCost = rawMaterialCost + materialBuyPrice
rawMaterialCost = rawMaterialCost + materialBuyPrice
return mw.html.create('tr')
return mw.html.create('tr')
Line 270: Line 272:
:done()
:done()
:done()
:done()
if args.output1 then
:IF(args.output1)

out
-- Values
-- Values
:tag('tr')
:tag('tr')
:tag('td')
:tag('td')
:css{ ['border-right'] = 'none' }
:css{ ['border-right'] = 'none' }
:wikitext('[[File:' .. args.output1 .. '.png|30px|link=' .. args.output1 .. ']]' or 'Unknown')
:wikitext('[[File:' .. args.output1 .. '.png|30px|link=' .. args.output1 .. ']]' or 'Unknown')
:done()
:tag('td')
:css{ ['border-left'] = 'none' }
:wikitext('[[' .. args.output1 .. ']]' or 'Unknown')
:done()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext(args.output1qty or 1)
:done()
:wikitext(currency_cell(output1TotalValue))
:done()
:done()
:tag('td')
:END()
-- Add profit data
:css{ ['border-left'] = 'none' }
:wikitext('[[' .. args.output1 .. ']]' or 'Unknown')
:done()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext(args.output1qty or 1)
:done()
:wikitext(currency_cell(output1TotalValue))
:done()
end
-- Add profit data
out
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')