Module:MinerPassiveList: Difference between revisions
offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all table
m (condense table by omitting " (skill node)" from the displayed links to the skill nodes (link still goes to node)) |
(offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all table) |
||
Line 1:
require('strict')
require('Module:Mw.html extension')
local lang = mw.getContentLanguage()
local plist = require('Module:ProfessionList')
local rts = require('Module:RecipeTreeSearch')
local p = {}
Line 10:
function p.main()
local queryString = '[[Category:Miner]] AND [[Category:Pages with activities]]'
local
return item.passive
end
local results = plist.generate_recipe_table(queryString,screenFunction)
results = p.formatResults(results)
Line 34 ⟶ 25:
--return '<pre>'..mw.text.jsonEncode(results, mw.text.JSON_PRETTY)..'</pre>'
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
-- protection against missing parameters
-- no downtime for passives
item.profit = item.sellPrice and item.sellPrice * 0.005
item.productPerHour = item.duration and 1 / item.duration * 3600
-- properties per hour
item.
item.
end
Line 87 ⟶ 55:
-- make the table
function p.displayTable(results)
--simple check for nil results
if results ==nil or results[1] == nil then
return 'No data found for table'
end
local out = mw.html.create('table')
:addClass('wikitable sortable')
Line 115 ⟶ 89:
:done()
:done()
for i, item in ipairs(results) do
Line 125 ⟶ 94:
--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.pageName,item.pageName))
-- products
:node(plist.three_column_image_text(item.product,0.005,'File:' .. item.product .. '.png',item.product,item.product))
-- products per hour
:tag('td')
:css{ ['text-align'] = 'right' }
Line 169 ⟶ 116:
-- profit per hour (coins)
:node(plist.currency_cell(item.
-- 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()
|