Module:AlchemistPassiveList: Difference between revisions

m
change "potion" to "product" and "reagent" to "material" so it matches all the other crafting profession tables. functionality unchanged.
(remove dependency on Module:Infobox Recipe, as it does not need the recursive recipe finding subroutine)
m (change "potion" to "product" and "reagent" to "material" so it matches all the other crafting profession tables. functionality unchanged.)
Line 57:
function p.formatResults(results)
 
-- iterate through potionsproducts
for _, item in ipairs(results) do
Line 66:
-- some fields are easy to work out
item.outputQuantity = 1
item.reagentsmaterials = {}
item.intermediates = {}
item.buy = 0
Line 79:
-- do not need to extensively search for subrecipes, as passive recipe
-- passive recipes only ever have one step
item.reagentsmaterials = unpackJSON.materials
-- 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 96:
end
item.buy = item.buy and item.buy + shopPrice * reagentmaterial.quantity
end
Line 107:
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100
 
-- potionsproducts made in 200 lots of 0.005, no downtime for passive activities
local batchSize = 200
local downtime = 0
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 131:
:tag('th')
:attr{ colspan = '3' }
:wikitext('PotionProduct')
:done()
:tag('th')
:wikitext('ReagentsMaterials')
:done()
:tag('th')
Line 197:
:IF(not(item.passiveActivity))
 
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