Editing Module:CarpenterPassiveList
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 58: | Line 58: | ||
function p.formatResults(results) |
function p.formatResults(results) |
||
-- iterate through |
-- iterate through potions |
||
for _, item in ipairs(results) do |
for _, item in ipairs(results) do |
||
Line 67: | Line 67: | ||
-- some fields are easy to work out |
-- some fields are easy to work out |
||
item.outputQuantity = 1 |
item.outputQuantity = 1 |
||
item. |
item.reagents = {} |
||
item.intermediates = {} |
item.intermediates = {} |
||
item.buy = 0 |
item.buy = 0 |
||
Line 82: | Line 82: | ||
local Materials = recipe._getTrueRawMaterials(unpackJSON.materials) |
local Materials = recipe._getTrueRawMaterials(unpackJSON.materials) |
||
if next(Materials) ~= nil then |
if next(Materials) ~= nil then |
||
item. |
item.reagents = Materials.rawMaterials |
||
item.intermediates = Materials.intermediateMaterials |
item.intermediates = Materials.intermediateMaterials |
||
end |
end |
||
-- iterate through |
-- iterate through reagents, adding buy price to running total (individuals not needed) |
||
item.buy = 0 |
item.buy = 0 |
||
for _, |
for _, reagent in ipairs(item.reagents) do |
||
--shamelessley lifted from Module:Products |
--shamelessley lifted from Module:Products |
||
local shopPriceQuery = '[[:+]][[Sold item::' .. |
local shopPriceQuery = '[[:+]][[Sold item::' .. reagent.name .. ']]|?Shop buy price|mainlabel=' .. reagent.name |
||
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {} |
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {} |
||
local shopPrice = 0 |
local shopPrice = 0 |
||
Line 101: | Line 101: | ||
end |
end |
||
item.buy = item.buy and item.buy + shopPrice * |
item.buy = item.buy and item.buy + shopPrice * reagent.quantity |
||
end |
end |
||
Line 151: | Line 151: | ||
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100 |
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100 |
||
-- |
-- potions made in 200 lots of 0.005, no downtime for passive activities |
||
local batchSize = 200 |
local batchSize = 200 |
||
local downtime = 0 |
local downtime = 0 |
||
item.duration = item.duration and item.duration + downtime/batchSize |
item.duration = item.duration and item.duration + downtime/batchSize |
||
item. |
item.potionPerHour = item.duration and 1 / item.duration * 3600 |
||
-- properties per hour |
-- properties per hour |
||
item.XPPerHour = item.XP and item. |
item.XPPerHour = item.XP and item.potionPerHour and math.floor(item.XP * item.potionPerHour) |
||
item.profitPerHour = item.profit and item. |
item.profitPerHour = item.profit and item.potionPerHour and math.floor(item.profit * item.potionPerHour) |
||
end |
end |
||
Line 175: | Line 175: | ||
:tag('th') |
:tag('th') |
||
:attr{ colspan = '3' } |
:attr{ colspan = '3' } |
||
:wikitext(' |
:wikitext('Potion') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:wikitext(' |
:wikitext('Reagents') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
Line 241: | Line 241: | ||
:IF(not(item.passiveActivity)) |
:IF(not(item.passiveActivity)) |
||
local |
local reagentCell = row:tag('td') |
||
for i, _ in ipairs(item. |
for i, _ in ipairs(item.reagents) do |
||
reagentCell:wikitext(item.reagents[i].quantity .. '× [[File:' .. item.reagents[i].name .. '.png|18px|link=' .. item.reagents[i].name .. ']]' .. '[[' .. item.reagents[i].name .. ']]<br>') |
|||
end |
end |
||