Module:ItemID

--- l10n info -- local l10n_info = { ['en'] = { ['th_id'] = 'ID', ['th_name'] = 'Name', ['th_internalname'] = 'Internal name', ['deprecated'] = '(Deprecated)', },	['de'] = { ['th_id'] = 'ID', ['th_name'] = 'Name', ['th_internalname'] = 'Interner Name', ['deprecated'] = '(veraltet)', },	['fr'] = { ['th_id'] = 'ID', ['th_name'] = 'Nom', ['th_internalname'] = 'Nom interne', ['deprecated'] = '(Obsolète)', },	['vi'] = { ['th_id'] = 'ID', ['th_name'] = 'Tên', },	['zh'] = { ['th_id'] = 'ID', ['th_name'] = '名称', ['th_internalname'] = '内部名称', ['deprecated'] = '(废弃)', }, }

--- The following is not related to l10n. --

local total = 5044 -- as in 1.4.0.5

local data = {} local unused = require('Module:Iteminfo/idSets').getIdSet('Unused')

local last = 0 local output = mw.html.create('table'):addClass('terraria sortable lined aligncenter')

local currentFrame local lang -- cache current lang. local l10n_table

local l10n = function(key) return l10n_table[key] or l10n_info['en'][key] end

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(id) if unused[id] then tr:tag('td'):attr('colspan', 3):tag('i'):addClass('note-text'):wikitext(l10n('deprecated')) else tr:tag('td'):wikitext(('%s'):format(currentFrame:expandTemplate{title = 'tr', args = {currentFrame:expandTemplate{title = 'itemNameFromId', args = {id, lang=lang}}}, lang = lang})) 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, currentFrame:expandTemplate{title = 'tr', args = {row.name}})) tr:tag('td'):wikitext(tostring(mw.html.create('code'):wikitext(row.internalname))) last = itemid end

return { main=function(frame) currentFrame = frame lang = frame.args['lang'] or frame:expandTemplate{ title='lang' } l10n_table = l10n_info[lang] or l10n_info['en'] local header = output:tag('tr') header:tag('th'):wikitext(l10n('th_id')) header:tag('th'):wikitext(l10n('th_name')) header:tag('th'):wikitext(l10n('th_internalname'))

-- There are more than 5000 items now. local result = mw.ext.cargo.query(		'Items',		'_pageName=page, itemid, name, imagefile, internalname',		{			groupBy = 'itemid',			orderBy = 'itemid',			where = 'itemid IS NOT NULL AND itemid <=4000 AND internalname <> "None" AND internalname <> "" ',			limit = 5000		}	) for _, row in ipairs(result) do		printRow(row) end local result = mw.ext.cargo.query(		'Items',		'_pageName=page, itemid, name, imagefile, internalname',		{			groupBy = 'itemid',			orderBy = 'itemid',			where = 'itemid IS NOT NULL AND itemid > 4000 AND internalname <> "None" 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(id) if unused[id] then tr:tag('td'):attr('colspan', 2):tag('i'):addClass('note-text'):wikitext(l10n('deprecated')) else tr:tag('td'):wikitext(('%s'):format(currentFrame:expandTemplate{title = 'ItemNameFromId', args = {id}})) tr:tag('td'):wikitext('???') end end

return output end, }