Editing Module:StonemasonEtchingList
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
require('strict') |
require('strict') |
||
require('Module:Mw.html extension') |
require('Module:Mw.html extension') |
||
⚫ | |||
local currency = require('Module:Currency') |
|||
local lang = mw.getContentLanguage() |
local lang = mw.getContentLanguage() |
||
⚫ | |||
local p = {} |
local p = {} |
||
Line 8: | Line 9: | ||
-- non dynamic module, no inputs |
-- non dynamic module, no inputs |
||
function p.main() |
function p.main() |
||
-- returns only directly needed parameter needed for the row, |
|||
-- other parameters are determined by subqueries of chained pages |
|||
local query = { |
|||
local queryString = '[[Category:Stonemason]] AND [[Category:Pages with recipes]]' |
|||
⚫ | |||
'?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) |
|||
⚫ | |||
⚫ | |||
end |
|||
⚫ | |||
local results = plist.generate_recipe_table(queryString,screenFunction) |
|||
results = p.formatResults(results) |
|||
return p.displayTable(results) |
return p.displayTable(results) |
||
Line 26: | Line 32: | ||
end |
end |
||
-- makes the html for the cells containing currency directly |
|||
-- do calculations and determine strings to go in cells |
|||
-- Replaces nil with an "unknown" cell |
|||
function p.formatResults(results) |
|||
⚫ | |||
if not amount then |
|||
--simple check for nil results |
|||
return mw.html.create('td') |
|||
if results ==nil or results[1] == nil then |
|||
:addClass('table-bg-gray') |
|||
return nil |
|||
⚫ | |||
⚫ | |||
:wikitext("''unknown''") |
|||
⚫ | |||
end |
end |
||
return currency._cell(amount, { html = 'yes' }) |
|||
-- 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 |
end |
||
-- make the table |
-- make the table |
||
function p.displayTable(results) |
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') |
local out = mw.html.create('table') |
||
:addClass('wikitable sortable') |
:addClass('wikitable sortable') |
||
Line 59: | Line 55: | ||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
⚫ | |||
:wikitext('Product') |
:wikitext('Product') |
||
:done() |
:done() |
||
:tag('th') |
:tag('th') |
||
:attr{ colspan = '2' } |
|||
:wikitext('Material') |
:wikitext('Material') |
||
:done() |
:done() |
||
Line 70: | Line 64: | ||
:done() |
:done() |
||
: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 |
for i, item in ipairs(results) do |
||
local row = out:tag('tr') |
local row = out:tag('tr') |
||
⚫ | |||
:css{ ['text-align'] = 'center' } |
|||
--level |
|||
: |
:wikitext(item.lvl) |
||
⚫ | |||
⚫ | |||
:wikitext('[[File:' .. item.name .. '.png|link=' .. item.name .. '|30px]] [[' .. item.name .. ']]') |
|||
⚫ | |||
:tag('td') |
|||
:wikitext('[[File:' .. item.rawmat .. '.png|30px|link=' .. item.rawmat .. ']] [[' .. item.rawmat .. ']]<br>') |
|||
:done() |
|||
⚫ | |||
:tag('td') |
:tag('td') |
||
:css{ ['text-align'] = 'center' } |
:css{ ['text-align'] = 'center' } |
||
:wikitext(item. |
:wikitext(item.XP and lang:formatNum(tonumber(item.XP))) |
||
:done() |
:done() |
||
:ELSE() |
:ELSE() |
||
:node(unknown_value_cell) |
|||
:node(plist.unknown_value_edit_cell(item.pageName,1)) |
|||
:END() |
:END() |
||
:done() |
|||
-- 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 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
:wikitext(item.xp and lang:formatNum(tonumber(item.xp))) |
|||
⚫ | |||
⚫ | |||
:node(plist.unknown_value_edit_cell(item.pageName,1)) |
|||
⚫ | |||
⚫ | |||
end |
end |
||