Module:MinerPassiveList: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(copy of merchant, but set up for only activities that produce items)
 
(add column for the profit from selling the items)
Line 55: Line 55:
-- iterate through products
-- iterate through products
for _, item in ipairs(results) do
for _, item in ipairs(results) do

-- profit from selling the items
--TESTING
item.product = item.product or ''
if not item.givesCoins then
-- query is: there is a shop object page that has this item AND has buy price cannot be "N/A"
local query = mw.smw.ask('[[Sold item::' .. item.product .. ']][[Shop sell price::!~N/A]]|?Shop sell price=data|mainlabel=-')
if type(query)=='table' then
-- price is returned as a number
item.coins = tonumber(query[1].data)*0.005 or 0
else
-- will return nil if the item is not in a shop, or if it is in a shop but can only be sold to the shop
item.coins = 0
end
end
-- no downtime for passives
-- no downtime for passives
item.productPerHour = item.duration and 1 / item.duration * 3600
item.productPerHour = item.duration and 1 / item.duration * 3600
Line 88: Line 100:
:tag('th')
:tag('th')
:wikitext('Quantity/hr')
:wikitext('Quantity/hr')
:done()
:tag('th')
:attr{ colspan = '10' }
:wikitext('Profit/hr')
:done()
:done()
:tag('th')
:tag('th')
Line 138: Line 154:
:done()
:done()
-- products per hour (coins or items)
-- products per hour (items)
:tag('td')
:tag('td')
:css{ ['text-align'] = 'right' }
:css{ ['text-align'] = 'right' }
:wikitext('0.9 × [[File:' .. item.product .. '.png|link=' .. item.product .. '|30x30px]]')
:wikitext('0.9 × [[File:' .. item.product .. '.png|link=' .. item.product .. '|30x30px]]')
:done()
:done()
-- profit per hour (coins)
:node(currency_cell(item.coinsPerHour))


-- XP
-- XP