Owl.png Wiki reading hard on the eyes? Try out our Dark Theme! Visit the preferences page while logged in and select Hydra Dark. Owl.png

Module:ResearchAmountList

From Terraria Wiki
Jump to: navigation, search
Lua logo.svg Documentation The documentation below is transcluded from Module:ResearchAmountList/doc. (edit | history)

Prints rows for the table on Journey mode/Research list. The function to invoke is go, possible arguments are the lower and upper item ID limits (default to 1 and 5044, respectively). For example, {{#invoke:ResearchAmountList|go|100|200}} will print 100 rows, for all items whose ID is between 100 and 200.

Data is taken from {{researchAmount}}.


------- l10n info --------------
local l10n_info = {
	['en'] = {
		['deprecated'] = 'Deprecated',
	}
}

------- 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 researchTable = {
	-- copied from Template:ResearchAmount
	['A'] = 50,
	['B'] = 25,
	['C'] = 5,
	['D'] = 1,
	['F'] = 2,
	['G'] = 3,
	['H'] = 10,
	['I'] = 15,
	['J'] = 30,
	['K'] = 99,
	['L'] = 100,
	['M'] = 200,
	['N'] = 20,
	['O'] = 400,
}

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 = {} }
	
	-- load data
	currentFrame:expandTemplate{ title = 'researchAmount', 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 } })
				local internalname = currentFrame:expandTemplate{ title = 'itemInternalNameFromId', args = { itemid } }
				research = currentFrame:callParserFunction{ name = '#dplvar', args = { '__researchamount:info:' .. internalname } }
				research = researchTable[research:upper()]
			end
			local sortbottom = ''
			if not research or research == '' 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,
}