Módulo:GELimits

De RuneScape Wiki
Ir para: navegação, pesquisa
Documentação do módulo
Esta documentação é transcluída de Módulo:GELimits/doc. [editar] [atualizar]
Módulo:GELimits carrega dados de Módulo:GELimits/data.

main takes a single unnamed argument that is the items name and returns the GE Limit of the item, or 0 if the item is not found.

table Generates tables of all the GE Limits, with == sections for # and each letter.


local p = {}
local data = mw.loadData('Módulo:GELimits/data')

function p.main(frame)
	local args = frame:getParent().args[1]
	
	return data[args] or 0
end

function p.table(frame)
	local sectionString = "#ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	
	local bySection = {}
	for name, _ in pairs(data) do
		local letter = string.sub(name, 1, 1)
		if letter ~= '%' then
			if string.find(sectionString, letter) == nil then
				letter = "#"
			end
			if bySection[letter] == nil then
				bySection[letter] = {}
			end
			table.insert(bySection[letter], name)
		end
	end
	
	local ret = {}
	for i = 1, #sectionString do
	    local sectionHeader = sectionString:sub(i, i)
	    local limits = bySection[sectionHeader]
	    if limits ~= nil then
	    	table.sort(limits)
	    	table.insert(ret, '\n\n=='..sectionHeader..'==\n')
	    	local inner = mw.html.create('table')
		    	:addClass('wikitable')
				:addClass('sortable')
				:tag('tr')
					:tag('th')
						:wikitext('Objeto')
					:done()
					:tag('th')
						:wikitext('Limite')
					:done()
				:done()
	    	for _, name in ipairs(limits) do
	    		local limit = data[name]
	    		row = inner:tag('tr')
	    			:tag('td')
	    				:wikitext('[[Mercado:' .. name .. '|' .. name .. ']]')
	    			:done()
	    			:tag('td')
	    				:wikitext(limit)
	    			:done()
	    		:done()
	    	end
	    	inner:done()
	    	table.insert(ret, tostring(inner))
	    end
	end
	return mw.text.trim(table.concat(ret, ''))
end

return p