Module:AlchemistList: Difference between revisions

m
change "potion" to "product" and "reagent" to "material" so it matches all the other crafting profession tables. functionality unchanged.
mNo edit summary
m (change "potion" to "product" and "reagent" to "material" so it matches all the other crafting profession tables. functionality unchanged.)
Line 51:
function p.formatResults(results)
 
-- iterate through potionsproducts
for _, item in ipairs(results) do
Line 63:
local Materials = recipe._getTrueRawMaterials(unpackJSON.materials)
if next(Materials) ~= nil then
item.reagentsmaterials = Materials.rawMaterials
item.intermediates = Materials.intermediateMaterials
end
-- iterate through reagentsmaterials, adding buy price to running total (individuals not needed)
item.buy = 0
for _, reagentmaterial in ipairs(item.reagentsmaterials) do
--shamelessley lifted from Module:Products
local shopPriceQuery = '[[:+]][[Sold item::' .. reagentmaterial.name .. ']]|?Shop buy price|mainlabel=' .. reagentmaterial.name
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {}
local shopPrice = 0
Line 82:
end
 
item.buy = item.buy and item.buy + shopPrice * reagentmaterial.quantity
end
Line 134:
local downtime = 40
item.duration = item.duration and item.duration + downtime/batchSize
item.potionPerHourproductPerHour = item.duration and 1 / item.duration * 3600
 
-- properties per hour
item.XPPerHour = item.XP and item.potionPerHourproductPerHour and math.floor(item.XP * item.potionPerHourproductPerHour)
item.profitPerHour = item.profit and item.potionPerHourproductPerHour and math.floor(item.profit * item.potionPerHourproductPerHour)
end
 
Line 154:
:tag('th')
:attr{ colspan = '3' }
:wikitext('PotionProduct')
:done()
:tag('th')
:wikitext('ReagentsMaterials')
:done()
:tag('th')
Line 218:
:done()
 
local reagentCellmaterialCell = row:tag('td')
 
for i, _ in ipairs(item.reagentsmaterials) do
reagentCellmaterialCell:wikitext(item.reagentsmaterials[i].quantity .. '&times; [[File:' .. item.reagentsmaterials[i].name .. '.png|18px|link=' .. item.reagentsmaterials[i].name .. ']] [[' .. item.reagentsmaterials[i].name .. ']]<br>')
end
10,210

edits