Module:LegacyRecipe

local p = {} function p.main(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end local filter = args.filter or "NULL"

local result = p.doQuery(filter) if not next(result) then return No results found! end

local html = mw.html.create if filter ~= "NULL" then html:tag('span'):wikitext(frame:preprocess('This item is the result of a Legacy Chest upgrade.')):tag('br') end local tbl = html:tag('table'):addClass('wikitable') tbl:tag('tr') :tag('th'):wikitext('Original'):done :tag('th'):wikitext('Upgrade'):done

for i, row in ipairs(result) do        tr = tbl:tag('tr') tr:tag('td'):cssText('text-align: center'):wikitext(frame:preprocess(' ' .. row.ingredient .. '')) tr:tag('td'):cssText('text-align: center'):wikitext(frame:preprocess(' ' .. row.result .. '')) end

return html end

function p.doQuery(filter) local fields = { '_pageName', 'ingredient', 'result' }

local crgWhere = "" if (filter ~= "NULL") then crgWhere = 'result="' .. filter .. '"' else crgWhere = "result NOT LIKE 'NULL'" end

local result = mw.ext.cargo.query('LegacyRecipes',       table.concat(fields,','),        {            orderBy = '_pageName',            groupBy = '_pageName',            where = crgWhere,            limit = 5000        }    )

return result end

return p