Module:StonemasonEtchingList: 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 (remove merchant hide module) |
(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 param = require( 'Module:Paramtest' )▼
local currency = require('Module:Currency')▼
local lang = mw.getContentLanguage()
local p = {}
Line 9:
-- non dynamic module, no inputs
function p.main()
local queryString = '[[Category:Stonemason]] AND [[Category:Pages with recipes]]'
'[[Uses facility::T.E.A. Machine]]', -- etching▼
}▼
end
local results = plist.generate_recipe_table(queryString,screenFunction)
results = p.formatResults(results)
return p.displayTable(results)
Line 32 ⟶ 27:
end
-- do calculations and determine strings to go in cells
function p.formatResults(results)
▲local function currency_cell(amount)
--simple check for nil results
if results ==nil or results[1] == nil then
return nil
:css{ ['text-align'] = 'center' }▼
:attr{ colspan = '10' }▼
:done()▼
end
-- iterate through products
for _, item in ipairs(results) do
item.material = (item.materials and item.materials[1] and item.materials[1].name) or ''
end
return results
end
-- 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 55 ⟶ 60:
:done()
:tag('th')
:wikitext('Product')
:done()
:tag('th')
:attr{ colspan = '2' }
:wikitext('Material')
:done()
Line 64 ⟶ 71:
:done()
:done()
for i, item in ipairs(results) do
local row = out:tag('tr')
:tag('td')▼
--level
:done()▼
:tag('td')▼
:done()▼
:IF(item.XP)▼
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.
:done()
:ELSE()
:node(plist.unknown_value_edit_cell(item.pageName,1))
:END()
-- product
:node(plist.two_column_image_text(item.product,'File:' .. item.product .. '.png',item.product,item.product))
:node(plist.two_column_image_text(item.material,'File:' .. item.material .. '.png',item.material,item.material))
-- XP
▲ :tag('td')
▲ :css{ ['text-align'] = 'center' }
:wikitext(item.xp and lang:formatNum(tonumber(item.xp)))
▲ :done()
:node(plist.unknown_value_edit_cell(item.pageName,1))
▲ :done()
end
|