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 = {}
 
 
local materials = {
	['Base parts'] = 'Base parts',
	['Blade parts'] = 'Blade parts',
	['Clear parts'] = 'Clear parts',
	['Connector parts'] = 'Connector parts',
	['Cover parts'] = 'Cover parts',
	['Crafted parts'] = 'Crafted parts',
	['Crystal parts'] = 'Crystal parts',
	['Delicate parts'] = 'Delicate parts',
	['Deflecting parts'] = 'Deflecting parts',
	['Flexible parts'] = 'Flexible parts',
	['Head parts'] = 'Head parts',
	['Magic parts'] = 'Magic parts',
	['Metallic parts'] = 'Metallic parts',
	['Organic parts'] = 'Organic parts',
	['Padded parts'] = 'Padded parts',
	['Plated parts'] = 'Plated parts',
	['Simple parts'] = 'Simple parts',
	['Smooth parts'] = 'Smooth parts',
	['Spiked parts'] = 'Spiked parts',
	['Spiritual parts'] = 'Spiritual parts',
	['Stave parts'] = 'Stave parts',
	['Tensile parts'] = 'Tensile parts',
	['Dextrous components'] = 'Dextrous components',
	['Direct components'] = 'Direct components',
	['Enhancing components'] = 'Enhancing components',
	['Ethereal components'] = 'Ethereal components',
	['Evasive components'] = 'Evasive components',
	['Healthy components'] = 'Healthy components',
	['Heavy components'] = 'Heavy components',
	['Imbued components'] = 'Imbued components',
	['Light components'] = 'Light components',
	['Living components'] = 'Living components',
	['Pious components'] = 'Pious components',
	['Powerful components'] = 'Powerful components',
	['Precious components'] = 'Precious components',
	['Precise components'] = 'Precise components',
	['Protective components'] = 'Protective components',
	['Refined components'] = 'Refined components',
	['Sharp components'] = 'Sharp components',
	['Strong components'] = 'Strong components',
	['Stunning components'] = 'Stunning components',
	['Subtle components'] = 'Subtle components',
	['Swift components'] = 'Swift components',
	['Variable components'] = 'Variable components',
	['Ancient components'] = 'Ancient components',
	['Armadyl components'] = 'Armadyl components',
	['Ascended components'] = 'Ascended components',
	['Bandos components'] = 'Bandos components',
	['Brassican components'] = 'Brassican components',
	['Corporeal components'] = 'Corporeal components',
	['Culinary components'] = 'Culinary components',
	['Dragonfire components'] = 'Dragonfire components',
	['Explosive components'] = 'Explosive components',
	['Fortunate components'] = 'Fortunate components',
	['Fungal components'] = 'Fungal components',
	['Harnessed components'] = 'Harnessed components',
	['Knightly components'] = 'Knightly components',
	['Noxious components'] = 'Noxious components',
	['Oceanic components'] = 'Oceanic components',
	['Pestiferous components'] = 'Pestiferous components',
	['Refined components'] = 'Refined components',
	['Resilient components'] = 'Resilient components',
	['Rumbling components'] = 'Rumbling components',
	['Saradomin components'] = 'Saradomin components',
	['Seren components'] = 'Seren components',
	['Shifting components'] = 'Shifting components',
	['Silent components'] = 'Silent components',
	['Zamorak components'] = 'Zamorak components',
	['Zaros components'] = 'Zaros components',
	['Base'] = 'Base parts',
	['Blade'] = 'Blade parts',
	['Clear'] = 'Clear parts',
	['Connector'] = 'Connector parts',
	['Cover'] = 'Cover parts',
	['Crafted'] = 'Crafted parts',
	['Crystal'] = 'Crystal parts',
	['Delicate'] = 'Delicate parts',
	['Deflecting'] = 'Deflecting parts',
	['Flexible'] = 'Flexible parts',
	['Head'] = 'Head parts',
	['Magic'] = 'Magic parts',
	['Metallic'] = 'Metallic parts',
	['Organic'] = 'Organic parts',
	['Padded'] = 'Padded parts',
	['Plated'] = 'Plated parts',
	['Simple'] = 'Simple parts',
	['Smooth'] = 'Smooth parts',
	['Spiked'] = 'Spiked parts',
	['Spiritual'] = 'Spiritual parts',
	['Stave'] = 'Stave parts',
	['Tensile'] = 'Tensile parts',
	['Dextrous'] = 'Dextrous components',
	['Direct'] = 'Direct components',
	['Enhancing'] = 'Enhancing components',
	['Ethereal'] = 'Ethereal components',
	['Evasive'] = 'Evasive components',
	['Healthy'] = 'Healthy components',
	['Heavy'] = 'Heavy components',
	['Imbued'] = 'Imbued components',
	['Light'] = 'Light components',
	['Living'] = 'Living components',
	['Pious'] = 'Pious components',
	['Powerful'] = 'Powerful components',
	['Precious'] = 'Precious components',
	['Precise'] = 'Precise components',
	['Protective'] = 'Protective components',
	['Refined'] = 'Refined components',
	['Sharp'] = 'Sharp components',
	['Strong'] = 'Strong components',
	['Stunning'] = 'Stunning components',
	['Subtle'] = 'Subtle components',
	['Swift'] = 'Swift components',
	['Variable'] = 'Variable components',
	['Ancient'] = 'Ancient components',
	['Armadyl'] = 'Armadyl components',
	['Ascended'] = 'Ascended components',
	['Bandos'] = 'Bandos components',
	['Brassican'] = 'Brassican components',
	['Corporeal'] = 'Corporeal components',
	['Culinary'] = 'Culinary components',
	['Dragonfire'] = 'Dragonfire components',
	['Explosive'] = 'Explosive components',
	['Fortunate'] = 'Fortunate components',
	['Fungal'] = 'Fungal components',
	['Harnessed'] = 'Harnessed components',
	['Knightly'] = 'Knightly components',
	['Noxious'] = 'Noxious components',
	['Oceanic'] = 'Oceanic components',
	['Pestiferous'] = 'Pestiferous components',
	['Refined'] = 'Refined components',
	['Resilient'] = 'Resilient components',
	['Rumbling'] = 'Rumbling components',
	['Saradomin'] = 'Saradomin components',
	['Seren'] = 'Seren components',
	['Shifting'] = 'Shifting components',
	['Silent'] = 'Silent components',
	['Zamorak'] = 'Zamorak components',
	['Zaros'] = 'Zaros components',
}
 
function get_mat_cats(parts)
	local pre = '[[Category:Items that disassemble into '
	local post = ']]'
	local cats = ''
	for _,v in ipairs(parts) do
		if materials[v.n] then
			cats = cats .. pre .. materials[v.n] .. post
		end
	end
	return cats
end
 
 
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
		if not string.find(junk, '%d+%.%d') then
	        table.insert(cats, '[[Category:Rounded junk chance]]')
        end
 
	    if junk == 0 then
	        table.insert(cats, '[[Category:Items that cannot disassemble into Junk]]')
            end
 
	    junk = string.gsub(junk, '%%', '') -- remove % if present
	    junk = junk .. '%'
	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 })
		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 })
		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 })
		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 })
		end
	end
 
	if (#special + #common + #uncommon + #rare) < 1 then
		table.insert(cats, '[[Category:Needs disassemble materials added]]')
	end
 
 
	if onmain then
		table.insert(cats, get_mat_cats(common))
		table.insert(cats, get_mat_cats(uncommon))
		table.insert(cats, get_mat_cats(rare))
		table.insert(cats, get_mat_cats(special))
 		cats = table.concat(cats)
	else
	    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', 'Experience received for disassembling')
					: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', 'Amount disassembled per action')
					: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', 'Base chance of receiving junk')
			        :wikitext('Base [[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:' .. materials[v.n] .. '.png|25px]] ' .. '[[' .. materials[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:' .. materials[v.n] .. '.png|25px]] ' .. '[[' .. materials[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:' .. materials[v.n] .. '.png|25px]] ' .. '[[' .. materials[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:' .. materials[v.n] .. '.png|25px]] ' .. '[[' .. materials[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.