FANDOM


-- <pre>
local p = {}
 
local mdata = mw.loadData('Module:Perks/materials')
local pdata = mw.loadData('Module:Perks/data')
local checkmark = '[[File:Yes check.svg|18px|center|link=]]'
 
function p.main(frame)
	local arg = frame:getParent().args[1] or ''
	local _arg = mw.text.decode(arg)
	_arg = string.lower(_arg)
	_arg = _arg:gsub('%(perk%)','')
	_arg = mw.text.trim(_arg)
	local argdata = pdata[_arg]
 
	if not argdata then
		return 'No perk as '..arg
	end
 
	local ret = mw.html.create('table')
				:addClass('wikitable')
				:tag('tr')
					:tag('th')
						:attr('colspan','2')
						:attr('rowspan','2')
						:wikitext('Material')
					:done()
					:tag('th')
						:attr('rowspan','2')
						:wikitext('Rarity')
					:done()
					:tag('th')
						:attr('colspan','5')
						:wikitext('Perk ranks with X materials')
					:done()
				:done()
				:tag('tr')
					:tag('th')
						:css('width','35px')
						:wikitext('1')
					:done()
					:tag('th')
						:css('width','35px')
						:wikitext('2')
					:done()
					:tag('th')
						:css('width','35px')
						:wikitext('3')
					:done()
					:tag('th')
						:css('width','35px')
						:wikitext('4')
					:done()
					:tag('th')
						:css('width','35px')
						:wikitext('5')
					:done()
				:done()
 
	local listmats = {}
 
	for x, v in pairs(mdata) do
		if v.perks[_arg] then
			table.insert(listmats,{ v.name, v.rarity, v.perks[_arg] })
		end
	end
	for x, v in pairs(listmats) do
		local newrow = ret:tag('tr')
		local matname = v[1]
		local matrarity = v[2]
		newrow
			:tag('td')
				:css('padding','4px')
				:wikitext(string.format('[[File:%s.png|link=%s|center]]',matname,matname))
			:done()
			:tag('td')
				:wikitext(string.format('[[%s]]',matname))
			:done()
			:tag('td')
				:wikitext(v[2])
			:done()
		for _, w in ipairs(v[3]) do
			local a,b = w[1],w[2]
			local c
			if a == b then
				c = a
			else
				c = mw.ustring.format('%s–%s',a,b)
			end
			local newtd = newrow:tag('td')
			if c == 0 then
				newtd:addClass('table-na')
			end
			newtd:css({ ['text-align'] = 'right' })
					:wikitext(c)
				:done()
		end
		newrow:done()
	end
 
	return ret
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.