FANDOM


-- <pre>
local edit_mod = require('Module:Edit button')
local edit = edit_mod('Unknown')
local onmain_mod = require('Module:Mainonly').on_main
local onmain = onmain_mod()
 
local p = {}
 
function p.main(frame)
	local args = frame:getParent().args
 
	local common = {}
	local rare = {}
	local uncommon = {}
	local special = {}
	local cats = {'[[Category:Items that can be disassembled]]'}
 
	local xp = tonumber(args.xp)
	if not xp then
		xp = edit
		table.insert(cats, '[[Category:Needs disassemble XP added]]')
	end
 
	local junk = tonumber(args.junk)
	if junk then
		junk = string.gsub(junk, '%%', '') .. '%' -- remove % if present
	else
		junk = edit
		table.insert(cats, '[[Category:Needs disassemble junk chance added]]')
	end
 
	local cqty = tonumber(args.compqty)
	if not cqty then
		cqty = edit
		table.insert(cats, '[[Category:Needs disassemble material quantity added]]')
	end
 
	local iqty = tonumber(args.itemqty) or 1
 
	local _common = mw.text.split(args.often or args.common or '','%s*,%s')
 
	for _, v in ipairs(_common) do
		v = string.gsub(v, '%[%[(.+)%]%]', '%1')
		local _,_,n,l = string.find(v,'(.+) ?%[(%d+)%]')
		if not n then
			n,l = v,level
		end
		if not tonumber(l) then
			l = 1
		end
		if v:find('%S') then
			table.insert(common,{ n = n, l = l })
			table.insert(cats, '[[Category:' .. n .. ']]')
		end
	end
 
	local _uncommon = mw.text.split(args.sometimes or args.uncommon or '','%s*,%s')
 
	for _, v in ipairs(_uncommon) do
		v = string.gsub(v, '%[%[(.+)%]%]', '%1')
		local _,_,n,l = string.find(v,'(.+) ?%[(%d+)%]')
		if not n then
			n,l = v,level
		end
		if not tonumber(l) then
			l = 1
		end
		if v:find('%S') then
			table.insert(uncommon,{ n = n, l = l })
			table.insert(cats, '[[Category:' .. n .. ']]')
		end
	end
	local _rare = mw.text.split(args.rarely or args.rare or '','%s*,%s')
 
	for _, v in ipairs(_rare) do
		v = string.gsub(v, '%[%[(.+)%]%]', '%1')
		local _,_,n,l = string.find(v,'(.+) ?%[(%d+)%]')
		if not n then
			n,l = v,level
		end
		if not tonumber(l) then
			l = 1
		end
		if v:find('%S') then
			table.insert(rare,{ n = n, l = l })
			table.insert(cats, '[[Category:' .. n .. ']]')
		end
	end
	local _special = mw.text.split(args.special or '','%s*,%s')
 
	for _, v in ipairs(_special) do
		v = string.gsub(v, '%[%[(.+)%]%]', '%1')
		local _,_,n,l = string.find(v,'(.+) ?%[(%d+)%]')
		if not n then
			n,l = v,level
		end
		if not tonumber(l) then
			l = 1
		end
		if v:find('%S') then
			table.insert(special,{ n = n, l = l })
			table.insert(cats, '[[Category:' .. n .. ']]')
		end
	end
 
	if (#special + #common + #uncommon + #rare) < 1 then
		table.insert(cats, '[[Category:Needs disassemble materials added]]')
	end
 
 
	if onmain then
		cats = table.concat(cats)
	else
	    --cats = table.concat(cats)
		cats = ''
	end
 
	return p._main(cats,special,common,uncommon,rare,xp,junk,iqty,cqty)
end
 
function p._main(cats,special,common,uncommon,rare,xp,junk,iqty,cqty)
	local ret = mw.html.create('div')
				:wikitext('This item can be disassembled with the [[Invention]] skill.')
				:wikitext(cats)
 
	local _t = ret:tag('table')
			:addClass('wikitable')
			:css('width','300px')
			:tag('tr')
				:tag('th')
					:attr('title', 'The amount of experience received from disassembling the item')
					:wikitext('[[Disassembly]] XP <sup><span style="color: #15f; font-style: italic; cursor: help; border-bottom: dotted 1px black;">?</span></sup>')
				:done()
				:tag('td')
					:wikitext(xp)
				:done()
			:done()
			:tag('tr')
				:tag('th')
					:attr('title', 'The amount of the item needed before disassembling')
					:wikitext('Item quantity required <sup><span style="color: #15f; font-style: italic; cursor: help; border-bottom: dotted 1px black;">?</span></sup>')
				:done()
				:tag('td')
					:wikitext(iqty)
				:done()
			:done()
			:tag('tr')
			    :tag('th')
			        :attr('title', 'The chance of receiving Junk')
			        :wikitext('Junk chance <sup><span style="color: #15f; font-style: italic; cursor: help; border-bottom: dotted 1px black;">?</span></sup>')
			    :done()
			    :tag('td')
			        :wikitext(junk)
			    :done()
			:done()
			:tag('tr')
				:tag('th')
					:attr('title', 'The amount of materials received normally (excluding specials), shown in chat window')
					:wikitext('Total [[materials]] received <sup><span style="color: #15f; font-style: italic; cursor: help; border-bottom: dotted 1px black;">?</span></sup>')
				:done()
				:tag('td')
					:wikitext(cqty)
				:done()
			:done()
			:tag('tr')
				:tag('td')
					:attr('colspan','2')
				:done()
			:done()
			:tag('tr')
				:tag('th')
					:attr('colspan','2')
					:css('background','#e5e5e5')
					:wikitext('Possible materials')
				:done()
			:done()
 
	if #special > 0 then
		_t:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:wikitext('Special')
			:done()
		:done()
 
		for _, v in ipairs(special) do
			_t:tag('tr')
				:tag('td')
					:attr('colspan', '2')
					:wikitext(v.l .. ' × [[File:' .. v.n .. '.png|25px]] ' .. '[[' .. v.n .. ']]')
				:done()
			:done()
		end
	end
 
	-- common
 
	if #common > 0 then
		_t:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:wikitext('Often')
			:done()
		:done()
 
		for _, v in ipairs(common) do
			_t:tag('tr')
				:tag('td')
					:attr('colspan', '2')
					:wikitext('[[File:' .. v.n .. '.png|25px]] ' .. '[[' .. v.n .. ']]')
				:done()
			:done()
		end
	end
 
	-- uncommon
	if #uncommon > 0 then
		_t:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:wikitext('Sometimes')
			:done()
		:done()
 
		for _, v in ipairs(uncommon) do
			_t:tag('tr')
				:tag('td')
					:attr('colspan', '2')
					:wikitext('[[File:' .. v.n .. '.png|25px]] ' .. '[[' .. v.n .. ']]')
				:done()
			:done()
		end
	end
 
	-- rare
	if #rare > 0 then
		_t:tag('tr')
			:tag('th')
				:attr('colspan', '2')
				:wikitext('Rarely')
			:done()
		:done()
 
		for _, v in ipairs(rare) do
			_t:tag('tr')
				:tag('td')
					:attr('colspan', '2')
					:wikitext('[[File:' .. v.n .. '.png|25px]] ' .. '[[' .. v.n .. ']]')
				:done()
			:done()
		end
	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.