FANDOM


-- <pre>
local p = {}
 
local mdata = mw.loadData('Module:Perks/materials')
local namedata = 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('components?',''):gsub('parts?','')
	_arg = mw.text.trim(_arg)
	local argdata = mdata[_arg]
 
	if not argdata then
		return 'No such material as '..arg
	end
 
	local ret = mw.html.create('table')
				:addClass('wikitable')
				:tag('tr')
					:tag('th')
						:attr('colspan','2')
						:attr('rowspan','2')
						:wikitext('Perk')
					:done()
					:tag('th')
						:attr('colspan','3')
						:wikitext('Gizmos')
					:done()
					:tag('th')
						:attr('colspan','5')
						:wikitext('Perk ranks with X materials')
					:done()
				:done()
				:tag('tr')
					:tag('th')
						:css('width','50px')
						:wikitext('Weapon')
					:done()
					:tag('th')
						:css('width','50px')
						:wikitext('Armour')
					:done()
					:tag('th')
						:css('width','50px')
						:wikitext('Tool')
					:done()
					: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()
 
	for x, v in pairs(argdata.perks) do
		local newrow = ret:tag('tr')
		local _perk = namedata[x]
		local perkname = _perk.name
		local perknameclean = string.gsub(perkname,' %(perk%)','')
		newrow
			:tag('td')
				:css({ background = '#09222F',
					padding = '4px' })
				:wikitext(string.format('[[File:%s.png|link=%s|center]]',perkname,perkname))
			:done()
			:tag('td')
				:wikitext(string.format('[[%s|%s]]',perkname,perknameclean))
			:done()
			:tag('td')
				:wikitext(_perk.weapon and checkmark or '')
			:done()
			:tag('td')
				:wikitext(_perk.armour and checkmark or '')
			:done()
			:tag('td')
				:wikitext(_perk.tool and checkmark or '')
			:done()
 
		for _, w in ipairs(v) 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.