Module:ResearchAmountList

De Terraria Wiki
Aller à la navigation Aller à la recherche
Voir aussi la page anglaise du module : Module:ResearchAmountList. Elle pourra contenir des informations plus complètes et actuelles.

Aucune sous-page de documentation n'existe déjà pour ce module. En créer une maintenant.


------- l10n info --------------
local l10n_info = {
	['en'] = {
		['deprecated'] = 'Deprecated',
	},
	['fr'] = {
		['deprecated'] = 'Obsolète',
	}
}

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

local iteminfo = require('Module:Iteminfo')
local unused = require('Module:Iteminfo/idSets').getIdSet('Unused')

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

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

local output = ''

return {
go = function(frame)
	currentFrame = frame
	
	lang = frame.args['lang'] or 'en'
	l10n_table = l10n_info[lang]
	
	local na = currentFrame:expandTemplate{ title = 'na', args = {} }
	
	local count = iteminfo.getItemStat(0, 'count')
	local first = tonumber(currentFrame.args['1']) or 1
	local last = tonumber(currentFrame.args['2']) or count
	
	for itemid = first, last do
		if first > 0 and last <= count then
			local itemname, research
			if unused[itemid] then
				itemname = ('<td class="note-text" style="font-style:italic;">%s</td>'):format(l10n('deprecated'))
			else
				itemname = ('<td>[[%s]]</td>'):format(currentFrame:expandTemplate{ title = 'itemNameFromId', args = { itemid } })
				research = iteminfo.getItemStat(itemid, 'sacrifices')
			end
			local sortbottom = ''
			if not research or research <= 0 then
				research = na
				sortbottom = 'class=sortbottom'
			end
			output = output .. ('<tr %s><td>%s</td>%s<td>%s</td>'):format(sortbottom, itemid, itemname, research)
		end
	end

	return output
end,
}