FANDOM


-- <pre>
local p = {}
 
local disdata = mw.loadData('Module:Disassemble/data')
local nocalc = {
    refined = 1,
    shifting = 1,
}
 
function p.main(frame)
	local args = frame:getParent().args
	local name = args[1] or ''
	local catname = name
	name = string.lower(name):gsub('parts?',''):gsub('components?','')
 
	name = mw.text.trim(name)
 
	local ret = {
	    string.format(':<i>Full list: [[:Category:Items that disassemble into %s]]</i>',catname)
	}
	if not nocalc[name:lower()] then
	    table.insert(ret, string.format(':<i>Calculator: [[Calculator:Disassembly by material/%s]]</i>',catname:gsub('parts?',''):gsub('components?','')))
	end
 
	local list = {}
	local _listed = {}
	local addcalc = {}
 
	for _, v in pairs(disdata) do
		local dislist = table.concat({v.often or '', v.sometimes or '', v.rarely or ''},',')
		local calc = v.nocalc == nil
 
		dislist = string.lower(dislist)
		dislist = mw.text.split(dislist,'%s*,%s*')
		for _, w in ipairs(dislist) do
			if w == name then
				if _listed[v.cat or ''] then
					-- do nothing
				else
					table.insert(list, { v.name, v.cat })
					_listed[v.cat] = true
					if calc then
						addcalc[v.cat] = true
					end
				end
			end
		end
	end
 
	for _, v in ipairs(list) do
		if addcalc[v[2]] then
			table.insert(ret,string.format('* [[:Category:Disassemble category/%s|%s]] ([[Calculator:Disassembly by category/%s|Cost analysis calculator]])',v[2],v[1],v[2]))
		else
			table.insert(ret,string.format('* [[:Category:Disassemble category/%s|%s]]',v[2],v[1]))
		end
	end
 
	return table.concat(ret,'\n')
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.