Module:Test

local i18n = { Id = 'ID', Name = 'Name', Image = 'Image', InternalName = 'Internal name', Deprecated = '(Deprecated)', }

local total = 5042 -- as in 1.4.0.3

local data={} local unused = require('Module:Iteminfo/idSets').getIdSet('Deprecated') local last = 0 local output = mw.html.create('table'):addClass('terraria sortable lined aligncenter') local currentFrame function printRow(row) local itemid = tonumber(row.itemid)

if itemid > last + 1 then for id = last+1, itemid-1 do			local tr = output:tag('tr') tr:tag('td'):wikitext(itemid) if unused[id] then tr:tag('td'):attr('colspan', 3):tag('i'):addClass('note-text'):wikitext(i18n.Deprecated) else tr:tag('td'):wikitext(('%s'):format(currentFrame:expandTemplate{title = 'itemNameFromId', args = {id}})) tr:tag('td'):wikitext('???') tr:tag('td'):wikitext('???') end end end

local tr = output:tag('tr') tr:tag('td'):wikitext(itemid) tr:tag('td'):wikitext(('%s'):format(row.page, row.name)) tr:tag('td'):wikitext((''):format(row.imagefile)) tr:tag('td'):wikitext(tostring(mw.html.create('code'):wikitext(row.internalname))) last = itemid

end

return { main=function(frame) currentFrame = frame local header = output:tag('tr') header:tag('th'):wikitext(i18n.Id) header:tag('th'):wikitext(i18n.Name) header:tag('th'):wikitext(i18n.Image) header:tag('th'):wikitext(i18n.InternalName)

-- There are more than 5000 items now. local result = mw.ext.cargo.query(		'Items_new',		'_pageName=page, itemid, name, imagefile, internalname',		{			groupBy = 'itemid',			orderBy = 'itemid',			where = 'itemid IS NOT NULL AND itemid <=4000 AND internalname <> ""',			limit = 5000		}	) for _, row in ipairs(result) do		printRow(row) end local result = mw.ext.cargo.query(		'Items_new',		'_pageName=page, itemid, name, imagefile, internalname',		{			groupBy = 'itemid',			orderBy = 'itemid',			where = 'itemid IS NOT NULL AND itemid > 4000 AND internalname <> ""',			limit = 5000		}	) for _, row in ipairs(result) do		printRow(row) end

-- tails for id = last+1, total do		local tr = output:tag('tr') tr:tag('td'):wikitext(itemid) if unused[id] then tr:tag('td'):attr('colspan', 3):tag('i'):addClass('note-text'):wikitext(i18n.Deprecated) else tr:tag('td'):wikitext(('%s'):format(currentFrame:expandTemplate{title = 'ItemNameFromId', args = {id}})) tr:tag('td'):wikitext('???') tr:tag('td'):wikitext('???') end end

return output end, }