Module:AlchemistPassiveList: Difference between revisions
m
Alsang moved page Module:PassivePotionList to Module:AlchemistPassiveList without leaving a redirect: match the naming convention of the other "List" modules
(change code base to match PotionList which uses extensive search for all subreceipes and reagents, but keep it showing non-recipe passive activities) |
m (Alsang moved page Module:PassivePotionList to Module:AlchemistPassiveList without leaving a redirect: match the naming convention of the other "List" modules) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1:
require('strict')
require('Module:Mw.html extension')
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
Line 14 ⟶ 13:
local query = {
'[[Uses facility::Passive Potion Station]] OR [[Variant of::Ebsworth Work]]',
'?Variant of #- = variant',▼
'?Profession Level A = lvl',
'? #- = name',
Line 19:
'?Activity XP = XP',
'?Activity duration = duration',
'?Activity coins = coins',▼
▲ '?Variant of #- = variant',
'?Value = sell',
▲ '?Activity coins = coins',
'sort = Profession Level A',
'limit = 500'
}
local results = mw.smw.ask(query)
-- criterion for if an entry is a recipe, or a passive activity
for _, item in ipairs(results) do
item.passiveActivity = item.variant=='Ebsworth Work'
results = p.formatResults(results)
Line 53 ⟶ 57:
function p.formatResults(results)
-- iterate through
for _, item in ipairs(results) do
-- recipe in a workable format
if item.
-- if it is
-- some fields are easy to work out
item.outputQuantity = 1
item.
item.intermediates = {}
item.buy = 0
else
local unpackJSON = mw.text.jsonDecode(item.recipeJSON)
item.outputQuantity = unpackJSON.output[1].quantity
-- SECTION REMOVED
-- do not need to extensively search for subrecipes, as passive recipe
-- passive recipes only ever have one step
item.materials = unpackJSON.materials
▲ end
▲ -- iterate through reagents, adding buy price to running total (individuals not needed)
item.buy = 0
for _,
--shamelessley lifted from Module:Products
local shopPriceQuery = '[[:+]][[Sold item::' ..
local shopPriceResult = mw.smw.ask(shopPriceQuery) or {}
local shopPrice = 0
Line 93 ⟶ 94:
else
item.buy = nil
item.buy = item.buy and item.buy + shopPrice * reagent.quantity▼
end
end
Line 145 ⟶ 107:
item.profitPerXP = item.profit and item.XP and math.floor(item.profit / item.XP * 100) / 100
--
local batchSize = 200
local downtime = 0
item.duration = item.duration and item.duration + downtime/batchSize
item.
-- properties per hour
item.XPPerHour = item.XP and item.
item.profitPerHour = item.profit and item.
end
Line 169 ⟶ 131:
:tag('th')
:attr{ colspan = '3' }
:wikitext('
:done()
:tag('th')
:wikitext('
:done()
:tag('th')
Line 233 ⟶ 195:
:done()
:IF(not(item.
local
for i, _ in ipairs(item.
end
|