Module:MinerList: Difference between revisions
offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all tables
m (spacing around images) |
(offload much of the search, screen, and format functions to the new ProfessionList module, so they work the same for all tables) |
||
Line 1:
require('strict')
require('Module:Mw.html extension')
local param = require( 'Module:Paramtest' )▼
local currency = require('Module:Currency')▼
local lang = mw.getContentLanguage()
local p = {}
Line 10:
function p.main()
local queryString = '[[Category:Miner]] AND [[Category:Pages with activities]]'
local
return not item.passive
end▼
local results = plist.generate_recipe_table(queryString,screenFunction)
▲ }
results = p.formatResults(results)
Line 35 ⟶ 25:
--return '<pre>'..mw.text.jsonEncode(results, mw.text.JSON_PRETTY)..'</pre>'
▲ end
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
Line 58 ⟶ 39:
--catch badly submitted data
item.product = item.product or ''
else▼
item.profit = nil▼
-- detect mine cart work
item.
if item.
item.profit = item.coins and tonumber(item.coins)
▲ else
end
-- profitability
item.profitPerXP = item.profit and item.
-- DOWNTIME VERY IMPORTANT FOR GATHERING TYPE PROFESSIONS
Line 87 ⟶ 58:
-- properties per hour
item.
item.profitPerHour = item.profit and item.productPerHour and math.floor(item.profit * item.productPerHour)
end
Line 96 ⟶ 67:
-- 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'
local out = mw.html.create('table')
:addClass('wikitable sortable')
Line 128 ⟶ 105:
:done()
:done()
for i, item in ipairs(results) do
Line 138 ⟶ 110:
--level
:IF(item.
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- gathering node
:node(plist.two_column_image_text(item.pageName,item.pageImage,item.pageName,item.pageName))
-- resource
:IF(item.
:tag('td')
:addClass('table-na')
Line 166 ⟶ 130:
:done()
:ELSE()
:node(plist.two_column_image_text(item.product,'File:' .. item.product .. '.png',item.product,item.product))
-- resource/hr
Line 182 ⟶ 138:
:done()
:ELSE()
:node(
:END()
:END()
-- economics
:node(plist.currency_cell(item.profit))
:node(plist.currency_cell(item.profitPerHour))
-- 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()
|