Module:Infobox Recipe: Difference between revisions
Switch to mw.html fluent builder; Use {{Currency cell}} to align currency
The Gaffer (talk | contribs) No edit summary |
(Switch to mw.html fluent builder; Use {{Currency cell}} to align currency) |
||
Line 1:
local currency = require('Module:Currency')
local function currency_cell(amount)
return currency._cell(amount, { html = 'yes' })
end
local p = {}
function p._main(frame)
local args = frame:getParent().args
local parse = require('Module:Param Parse')
local yn = require('Module:Yesno')
Line 87 ⟶ 91:
local materialBuyPrice = getBuyPrice(item)
rawMaterialCost = rawMaterialCost + materialBuyPrice
return mw.html.create('tr')
:tag('td')
:done()
:tag('td')
:wikitext('[[' .. item.name .. ']]')
:done()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext(quantity or 1)
:done()
:wikitext(currency_cell(materialBuyPrice))
:done()
end
--Creates a row suitable for the intermediate materials section of the infobox. Quantity is optional, if no value is provided it will default to 1
local function createIntermediateMaterialRow(item, quantity)
local facility = getFacility(item)
return mw.html.create('tr')
:tag('td')
:wikitext('[[File:' .. item .. '.png|30px]]')
:done()
:wikitext('[[' .. item .. ']]')
:done()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext(quantity or 1)
:done()
:tag('td')
:attr{ colspan = '10' }
:css{ ['text-align'] = 'right' }
:wikitext('[[File:' .. facility .. '.png|30px]] [[' .. facility .. ']]')
:done()
:done()
end
-- Recipe Table Head
local out =
:tag('tr')
:tag('th')
:wikitext('Requirements')
:done()
:done()
:tag('tr')
:tag('th')
:attr{ colspan = '2' }
:wikitext('Facility')
:done()
:tag('td')
:attr{ colspan = '11' }
:wikitext(args.facility and '[[' .. args.facility .. ']]' or 'Unknown')
:done()
:done()
:tag('tr')
:tag('th')
:attr{ colspan = '2' }
:wikitext('Profession')
:done()
:tag('th')
:wikitext('Level')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('XP')
:done()
:done()
:tag('tr')
:tag('td')
:attr{ colspan = '2' }
:css{ ['text-align'] = 'center' }
:wikitext(args.profession and '[[' .. args.profession .. ']]' or 'Unknown')
:done()
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(args.level or 'Unknown')
:done()
:tag('td')
:attr{ colspan = '10' }
:css{ ['text-align'] = 'center' }
:wikitext(args.exp or 'Unknown')
:done()
:done()
-- Add raw materials
:tag('tr')
:tag('th')
:attr{ colspan = '2' }
:wikitext('Raw Ingredient')
:done()
:tag('th')
:wikitext('Quantity')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Cost')
:done()
:done()
for _, material in ipairs(rawMaterials) do
end
-- Add total raw cost
out
:tag('tr')
:tag('th')
:attr{ colspan = '3' }
:wikitext('Total Raw cost')
:done()
:wikitext(currency_cell(rawMaterialCost))
:done()
-- Add Intermediate steps if required
-- Headers
if next(intermediateMaterials) ~= nil then
-- Headers
out
:tag('tr')
:tag('th')
:attr{ colspan = '2' }
:wikitext('Intermediate Ingredient')
:done()
:tag('th')
:wikitext('Quantity')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Faciltity')
:done()
:done()
for _, material in ipairs(intermediateMaterials) do
end
end
-- Add output data
out
-- Headers
:tag('tr')
:tag('th')
:attr{ colspan = '2' }
:wikitext('Output')
:done()
:tag('th')
:wikitext('Quantity')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Value')
:done()
:done()
:tag('tr')
:tag('td')
:wikitext('[[File:' .. args.output1 .. '.png|30px]]')
:done()
:tag('td')
:wikitext(args.output1 and '[[' .. args.output1 .. ']]' or 'Unknown')
:done()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext(args.output1qty or 1)
:done()
:wikitext(currency_cell(output1TotalValue))
:done()
:tag('tr')
:tag('th')
:attr{ colspan = '3' }
:wikitext('Profit')
:done()
:wikitext(currency_cell(output1TotalValue - rawMaterialCost))
:done()
return
end
|