Module:WoodcutterPassiveList: Difference between revisions
m
add purge link
(based on MinerPassiveList) |
Californ1a (talk | contribs) m (add purge link) |
||
(5 intermediate revisions by one other user not shown) | |||
Line 1:
require('strict')
require('Module:Mw.html extension')
local lang = mw.getContentLanguage()
local plist = require('Module:ProfessionList')
local purge = require('Module:Purge')._purge
local p = {}
Line 10:
function p.main()
local queryString = '[[Category:Woodcutter]] AND [[Category:Pages with activities]]'
local function screenFunction(item)
return item.passive
end
local results = plist.generate_recipe_table(queryString,screenFunction)
results = p.formatResults(results)
Line 37 ⟶ 27:
end
-- do calculations and determine strings to go in cells
function p.formatResults(results)
--simple check for nil results
if results==nil or results[1]==nil then
return nil
end
-- iterate through products
for _, item in ipairs(results) do
item.givesCoins = string.find(item.product,'Split')
if item.givesCoins then
item.profit = item.coins and tonumber(item.coins)
else
item.profit = item.sellPrice
end
-- no downtime for passives
item.productPerHour = item.duration and 1 / item.duration * 3600
-- properties per hour
item.
item.coinsPerHour = item.
end
Line 113 ⟶ 58:
-- make the table
function p.displayTable(results)
--simple check for nil results
if results==nil or results[1]==nil then
return nil
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
:tag('caption')
:wikitext('This list is updated dynamically. '..purge())
:done()
:tag('tr')
:tag('th')
Line 121 ⟶ 75:
:tag('th')
:attr{ colspan = '2' }
:wikitext('
:done()
:tag('th')
Line 141 ⟶ 95:
:done()
:done()
for i, item in ipairs(results) do
Line 151 ⟶ 100:
--level
:IF(item.
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- activity
:node(plist.two_column_image_text(item.pageName,item.pageImage,item.product,item.product))
-- products (coins or items)
:
:IF(item.profit)
:tag('td')
:css{ ['border-right'] = '0', ['text-align'] = 'right' }
:addClass('plinkt-link no-border')
:attr{ ['data-sort-value'] = item.product }
:wikitext(item.profit)
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:
:
:css{ ['border-right'] = '0', ['text-align'] = 'center' }
:addClass('plinkt-link no-border')
:wikitext('[[File:Copper coin.png|20x20px]]')
:done()
:tag('td')
:addClass('plinkt-link no-border')
:wikitext('Coins')
:done()
:ELSE()
:node(plist.three_column_image_text(item.product,item.output[1].quantity,'File:'..item.product..'.png',item.product,item.product))
:END()
-- products per hour (items)
:
:tag('td')
:addClass('table-na')
:
:done()
:ELSE()
:tag('td')
:css{ ['text-align'] = 'right' }
:wikitext('0.9 × [[File:' .. item.product .. '.png|link=' .. item.product .. '|30x30px]]')
:done()
:END()
-- profit per hour (coins)
:node(plist.currency_cell(item.coinsPerHour))
-- XP
:IF(item.
:tag('td')
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- XP per hour
:IF(item.
:tag('td')
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_cell(1))
:END()
|