Module:StonemasonEtchingList
Module documentation
This documentation is transcluded from Module:StonemasonEtchingList/doc. [edit] [history] [purge]
This module does not have any documentation. Please consider adding documentation at Module:StonemasonEtchingList/doc. [edit]
Module:StonemasonEtchingList's function main is invoked by Template:StonemasonEtchingList.
Module:StonemasonEtchingList requires
.require('strict')
require('Module:Mw.html extension')
local recipe = require('Module:Infobox Recipe') -- to make use of its extensive material searching function
local param = require( 'Module:Paramtest' )
local currency = require('Module:Currency')
local discount = require('Module:MerchantHideDiscount')
local lang = mw.getContentLanguage()
local p = {}
-- non dynamic module, no inputs
function p.main()
-- returns only directly needed parameter needed for the row,
-- other parameters are determined by subqueries of chained pages
local query = {
'[[Uses facility::T.E.A. Machine]]', -- etching
'?Uses facility #- = facility',
'?Profession Level A = lvl',
'? #- = name',
'?Recipe JSON = recipeJSON',
'?Activity XP = XP',
'?Uses item #- = rawmat',
'sort = Profession Level A',
'limit = 500'
}
local results = mw.smw.ask(query)
return p.displayTable(results)
--for debugging
--return '<pre>'..mw.text.jsonEncode(results, mw.text.JSON_PRETTY)..'</pre>'
end
-- makes the html for the cells containing currency directly
-- Replaces nil with an "unknown" cell
local function currency_cell(amount)
if not amount then
return mw.html.create('td')
:addClass('table-bg-gray')
:css{ ['text-align'] = 'center' }
:attr{ colspan = '10' }
:wikitext("''unknown''")
:done()
end
return currency._cell(amount, { html = 'yes' })
end
-- make the table
function p.displayTable(results)
local out = mw.html.create('table')
:addClass('wikitable sortable')
:tag('tr')
:tag('th')
:wikitext('[[File:Stonemason small icon.png|15px]] Level')
:done()
:tag('th')
:wikitext('Product')
:done()
:tag('th')
:wikitext('Material')
:done()
:tag('th')
:wikitext('XP')
:done()
:done()
local unknown_value_cell = mw.html.create('td')
:addClass('table-bg-gray')
:css{ ['text-align'] = 'center' }
:wikitext("''unknown''")
for i, item in ipairs(results) do
local row = out:tag('tr')
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.lvl)
:done()
:tag('td')
:wikitext('[[File:' .. item.name .. '.png|link=' .. item.name .. '|30px]][[' .. item.name .. ']]')
:done()
:tag('td')
:wikitext('[[File:' .. item.rawmat .. '.png|30px|link=' .. item.rawmat .. ']][[' .. item.rawmat .. ']]<br>')
:done()
:IF(item.XP)
:tag('td')
:css{ ['text-align'] = 'center' }
:wikitext(item.XP and lang:formatNum(tonumber(item.XP)))
:done()
:ELSE()
:node(unknown_value_cell)
:END()
:done()
end
return out
end
return p