Module:Sandbox/User:BlackHawk/Databox Excavation Site

From the RuneScape Wiki, the wiki for all things RuneScape
Jump to navigation Jump to search
Module documentation
This documentation is transcluded from Template:Module sandbox/doc. [edit] [history] [purge]
Module:Sandbox/User:BlackHawk/Databox Excavation Site requires Module:Infobox.
Module:Sandbox/User:BlackHawk/Databox Excavation Site requires Module:Mainonly.
Module:Sandbox/User:BlackHawk/Databox Excavation Site requires Module:Paramtest.
Module:Sandbox/User:BlackHawk/Databox Excavation Site requires Module:Yesno.
Function list
L 12 — p.main
L 235 — addcategories

This module is a sandbox for BlackHawk. It can be used to test changes to existing modules, prototype new modules, or just experimenting with lua features.

Invocations of this sandbox should be kept in userspace; if the module is intended for use in other namespaces, it should be moved out of the sandbox into a normal module and template.

This default documentation can be overridden by creating the /doc subpage of this module, as normal.

--------------------------
-- Module for [[Template:Databox Excavation Site]]
------------------------
local p = {}

local onmain = require('Module:Mainonly').on_main
local yesno = require('Module:Yesno')
local paramtest = require('Module:Paramtest')
local infobox = require('Module:Infobox')

-- Main function called with invokes
function p.main(frame)
	local args = frame:getParent().args
	local ret = infobox.new(args)

	ret:defineParams{
		{ name = 'name', func = 'name' },
		{ name = 'requirements', func = 'has_content' },
		{ name = 'third age iron', func = 'has_content' },
		{ name = 'zarosian insignia', func = 'has_content' },
		{ name = 'imperial steel', func = 'has_content' },
		{ name = 'samite silk', func = 'has_content' },
		{ name = 'white oak', func = 'has_content' },
		{ name = 'goldrune', func = 'has_content' },
		{ name = 'orthenglass', func = 'has_content' },
		{ name = 'vellum', func = 'has_content' },
		{ name = 'cadmium red', func = 'has_content' },
		{ name = 'tyrian purple', func = 'has_content' },
		{ name = 'ancient vis', func = 'has_content' },
		{ name = 'leather scraps', func = 'has_content' },
		{ name = 'chaotic brimstone', func = 'has_content' },
		{ name = 'demonhide', func = 'has_content' },
		{ name = 'hellfire metal', func = 'has_content' },
		{ name = 'eye of dagon', func = 'has_content' },
		{ name = 'keramos', func = 'has_content' },
		{ name = 'white marble', func = 'has_content' },
		{ name = 'cobalt blue', func = 'has_content' },
		{ name = 'star of saradomin', func = 'has_content' },
		{ name = 'everlight silvthril', func = 'has_content' },
		{ name = 'blood of orcus', func = 'has_content' },
		{ name = 'stormguard steel', func = 'has_content' },
		{ name = 'wings of war', func = 'has_content' },
		{ name = 'armadylean yellow', func = 'has_content' },
		{ name = 'malachite green', func = 'has_content' },
		{ name = 'mark of the kyzaj', func = 'has_content' },
		{ name = 'vulcanised rubber', func = 'has_content' },
		{ name = 'animal furs', func = 'has_content' },
		{ name = 'warforged bronze', func = 'has_content' },
		{ name = 'fossilised bone', func = 'has_content' },
		{ name = 'yu biusk clay', func = 'has_content' },
		{ name = 'aetherium alloy', func = 'has_content' },
		{ name = 'quintessence', func = 'has_content' },
		{ name = 'soapstone', func = 'has_content' },
		{ name = 'felt', func = 'has_content' },
		{ name = 'dragon metal', func = 'has_content' },
		{ name = 'orgone', func = 'has_content' },
		{ name = 'carbon black', func = 'has_content' },
		{ name = 'compass rose', func = 'has_content' }
	}

	ret:setMaxButtons(4)
	ret:setAddRSWDataboxClass(true)
	ret:create()
	ret:cleanParams()
	ret:customButtonPlacement(true)
	
	ret:defineLinks({ links = {{ 'Template:%s', 'Databox' },
		{ 'Template_talk:%s', 'Talk page' }}, colspan = '2' })

	ret:defineName('Databox Excavation Site')
	ret:addClass('wikitable')

	ret:addButtonsCaption()

	-- PARAMETER: name
	ret:addRow{
		{ tag = 'argh', content = 'name', class='infobox-header',  colspan = '2' }
	}
	
	-- PARAMETER: requirements
	if ret:paramDefined('requirements') then
		ret:addRow{
			{ tag = 'th', content = 'Requirements' },
			{ tag = 'argd', content = 'requirements' }
		}
	end
	
	-- PARAMETER: caches
	if ret:paramDefined('third age iron') or ret:paramDefined('zarosian insignia') or ret:paramDefined('imperial steel') or ret:paramDefined('samite silk') or ret:paramDefined('white oak') 
	or ret:paramDefined('goldrune') or ret:paramDefined('orthenglass') or ret:paramDefined('vellum') or ret:paramDefined('cadmium red') or ret:paramDefined('tyrian purple') 
	or ret:paramDefined('ancient vis') or ret:paramDefined('leather scraps') or ret:paramDefined('chaotic brimstone') or ret:paramDefined('demonhide') or ret:paramDefined('hellfire metal') 
	or ret:paramDefined('eye of dagon') or ret:paramDefined('keramos') or ret:paramDefined('white marble') or ret:paramDefined('cobalt blue') or ret:paramDefined('star of saradomin') 
	or ret:paramDefined('everlight silvthril') or ret:paramDefined('blood of orcus') or ret:paramDefined('stormguard steel') or ret:paramDefined('wings of war') or ret:paramDefined('armadylean yellow') 
	or ret:paramDefined('malachite green') or ret:paramDefined('mark of the kyzaj') or ret:paramDefined('vulcanised rubber') or ret:paramDefined('animal furs') or ret:paramDefined('warforged bronze') 
	or ret:paramDefined('fossilised bone') or ret:paramDefined('yu biusk clay') or ret:paramDefined('aetherium alloy') or ret:paramDefined('quintessence') or ret:paramDefined('soapstone') 
	or ret:paramDefined('felt') or ret:paramDefined('dragon metal') or ret:paramDefined('orgone') or ret:paramDefined('carbon black') or ret:paramDefined('compass rose') then
		local caches = {}
		if ret:paramDefined('third age iron') then
			table.insert(caches,'* '..ret:param('third age iron')..' [[Material cache (Third Age iron)|Third Age iron]]')
		end
		if ret:paramDefined('zarosian insignia') then
			table.insert(caches,'* '..ret:param('zarosian insignia')..' [[Material cache (Zarosian insignia)|Zarosian insignia]]')
		end
		if ret:paramDefined('imperial steel') then
			table.insert(caches,'* '..ret:param('imperial steel')..' [[Material cache (imperial steel)|imperial steel]]')
		end
		if ret:paramDefined('samite silk') then
			table.insert(caches,'* '..ret:param('samite silk')..' [[Material cache (samite silk)|samite silk]]')
		end
		if ret:paramDefined('white oak') then
			table.insert(caches,'* '..ret:param('white oak')..' [[Material cache (white oak)|white oak]]')
		end
		if ret:paramDefined('goldrune') then
			table.insert(caches,'* '..ret:param('goldrune')..' [[Material cache (goldrune)|goldrune]]')
		end
		if ret:paramDefined('orthenglass') then
			table.insert(caches,'* '..ret:param('orthenglass')..' [[Material cache (orthenglass)|orthenglass]]')
		end
		if ret:paramDefined('vellum') then
			table.insert(caches,'* '..ret:param('vellum')..' [[Material cache (vellum)|vellum]]')
		end
		if ret:paramDefined('cadmium red') then
			table.insert(caches,'* '..ret:param('cadmium red')..' [[Material cache (cadmium red)|cadmium red]]')
		end
		if ret:paramDefined('tyrian purple') then
			table.insert(caches,'* '..ret:param('tyrian purple')..' [[Material cache (Tyrian purple)|Tyrian purple]]')
		end
		if ret:paramDefined('ancient vis') then
			table.insert(caches,'* '..ret:param('ancient vis')..' [[Material cache (ancient vis)|ancient vis]]')
		end
		if ret:paramDefined('leather scraps') then
			table.insert(caches,'* '..ret:param('leather scraps')..' [[Material cache (leather scraps)|leather scraps]]')
		end
		if ret:paramDefined('chaotic brimstone') then
			table.insert(caches,'* '..ret:param('chaotic brimstone')..' [[Material cache (chaotic brimstone)|chaotic brimstone]]')
		end
		if ret:paramDefined('demonhide') then
			table.insert(caches,'* '..ret:param('demonhide')..' [[Material cache (demonhide)|demonhide]]')
		end
		if ret:paramDefined('hellfire metal') then
			table.insert(caches,'* '..ret:param('hellfire metal')..' [[Material cache (hellfire metal)|hellfire metal]]')
		end
		if ret:paramDefined('eye of dagon') then
			table.insert(caches,'* '..ret:param('eye of dagon')..' [[Material cache (Eye of Dagon)|Eye of Dagon]]')
		end
		if ret:paramDefined('keramos') then
			table.insert(caches,'* '..ret:param('keramos')..' [[Material cache (keramos)|keramos]]')
		end
		if ret:paramDefined('white marble') then
			table.insert(caches,'* '..ret:param('white marble')..' [[Material cache (white marble)|white marble]]')
		end
		if ret:paramDefined('cobalt blue') then
			table.insert(caches,'* '..ret:param('cobalt blue')..' [[Material cache (cobalt blue)|cobalt blue]]')
		end
		if ret:paramDefined('star of saradomin') then
			table.insert(caches,'* '..ret:param('star of saradomin')..' [[Material cache (Star of Saradomin)|Star of Saradomin]]')
		end
		if ret:paramDefined('everlight silvthril') then
			table.insert(caches,'* '..ret:param('everlight silvthril')..' [[Material cache (Everlight silvthril)|Everlight silvthril]]')
		end
		if ret:paramDefined('blood of orcus') then
			table.insert(caches,'* '..ret:param('blood of orcus')..' [[Material cache (Blood of Orcus)|Blood of Orcus]]')
		end
		if ret:paramDefined('stormguard steel') then
			table.insert(caches,'* '..ret:param('stormguard steel')..' [[Material cache (Stormguard steel)|Stormguard steel]]')
		end
		if ret:paramDefined('wings of war') then
			table.insert(caches,'* '..ret:param('wings of war')..' [[Material cache (Wings of War)|Wings of War]]')
		end
		if ret:paramDefined('armadylean yellow') then
			table.insert(caches,'* '..ret:param('armadylean yellow')..' [[Material cache (Armadylean yellow)|Armadylean yellow]]')
		end
		if ret:paramDefined('malachite green') then
			table.insert(caches,'* '..ret:param('malachite green')..' [[Material cache (malachite green)|malachite green]]')
		end
		if ret:paramDefined('mark of the kyzaj') then
			table.insert(caches,'* '..ret:param('mark of the kyzaj')..' [[Material cache (Mark of the Kyzaj)|Mark of the Kyzaj]]')
		end
		if ret:paramDefined('vulcanised rubber') then
			table.insert(caches,'* '..ret:param('vulcanised rubber')..' [[Material cache (vulcanised rubber)|vulcanised rubber]]')
		end
		if ret:paramDefined('animal furs') then
			table.insert(caches,'* '..ret:param('animal furs')..' [[Material cache (animal furs)|animal furs]]')
		end
		if ret:paramDefined('warforged bronze') then
			table.insert(caches,'* '..ret:param('warforged bronze')..' [[Material cache (warforged bronze)|warforged bronze]]')
		end
		if ret:paramDefined('fossilised bone') then
			table.insert(caches,'* '..ret:param('fossilised bone')..' [[Material cache (fossilised bone)|fossilised bone]]')
		end
		if ret:paramDefined('yu biusk clay') then
			table.insert(caches,'* '..ret:param('yu biusk clay')..' [[Material cache (Yu\'biusk clay)|Yu\'biusk clay]]')
		end
		if ret:paramDefined('aetherium alloy') then
			table.insert(caches,'* '..ret:param('aetherium alloy')..' [[Material cache (aetherium alloy)|aetherium alloy]]')
		end
		if ret:paramDefined('quintessence') then
			table.insert(caches,'* '..ret:param('quintessence')..' [[Material cache (quintessence)|quintessence]]')
		end
		if ret:paramDefined('soapstone') then
			table.insert(caches,'* '..ret:param('soapstone')..' [[Material cache (soapstone)|soapstone]]')
		end
		if ret:paramDefined('felt') then
			table.insert(caches,'* '..ret:param('felt')..' [[Material cache (felt)|felt]]')
		end
		if ret:paramDefined('dragon metal') then
			table.insert(caches,'* '..ret:param('dragon metal')..' [[Material cache (dragon metal)|dragon metal]]')
		end
		if ret:paramDefined('orgone') then
			table.insert(caches,'* '..ret:param('orgone')..' [[Material cache (orgone)|orgone]]')
		end
		if ret:paramDefined('carbon black') then
			table.insert(caches,'* '..ret:param('carbon black')..' [[Material cache (carbon black)|carbon black]]')
		end
		if ret:paramDefined('compass rose') then
			table.insert(caches,'* '..ret:param('compass rose')..' [[Material cache (compass rose)|compass rose]]')
		end
		mw.logObject(caches)
		ret:addRow{
			{ tag = 'th', content = 'Caches' },
			{ tag = 'td', content = '\n'..table.concat(caches,'\n') }
		}
	end
	
	ret:finish()
	
	if onmain() then
		local a1 = ret:param('all')
		local a2 = ret:categoryData()
		ret:wikitext(addcategories(a1, a2))
	end
	return ret:tostring()
end

function addcategories(args, catargs)
	local ret = { 'Excavation sites' }

	local cat_map = {
		-- Added if the parameter has content
		defined = {
			['third age iron'] = 'Excavation sites with Third Age iron caches',
			['zarosian insignia'] = 'Excavation sites with Zarosian insignia caches',
			['imperial steel'] = 'Excavation sites with imperial steel caches',
			['samite silk'] = 'Excavation sites with samite silk caches',
			['white oak'] = 'Excavation sites with white oak caches',
			['goldrune'] = 'Excavation sites with goldrune caches',
			['orthenglass'] = 'Excavation sites with orthenglass caches',
			['vellum'] = 'Excavation sites with vellum caches',
			['cadmium red'] = 'Excavation sites with cadmium red caches',
			['tyrian purple'] = 'Excavation sites with Tyrian purple caches',
			['ancient vis'] = 'Excavation sites with ancient vis caches',
			['leather scraps'] = 'Excavation sites with leather scraps caches',
			['chaotic brimstone'] = 'Excavation sites with chaotic brimstone caches',
			['demonhide'] = 'Excavation sites with demonhide caches',
			['hellfire metal'] = 'Excavation sites with hellfire metal caches',
			['eye of dagon'] = 'Excavation sites with Eye of Dagon caches',
			['keramos'] = 'Excavation sites with keramos caches',
			['white marble'] = 'Excavation sites with white marble caches',
			['cobalt blue'] = 'Excavation sites with cobalt blue caches',
			['star of saradomin'] = 'Excavation sites with Star of Saradomin caches',
			['everlight silvthril'] = 'Excavation sites with Everlight silvthril caches',
			['blood of orcus'] = 'Excavation sites with Blood of Orcus caches',
			['stormguard steel'] = 'Excavation sites with Stormguard steel caches',
			['wings of war'] = 'Excavation sites with Wings of War caches',
			['armadylean yellow'] = 'Excavation sites with Armadylean yellow caches',
			['malachite green'] = 'Excavation sites with malachite green caches',
			['mark of the kyzaj'] = 'Excavation sites with Mark of the Kyzaj caches',
			['vulcanised rubber'] = 'Excavation sites with vulcanised rubber caches',
			['animal furs'] = 'Excavation sites with animal furs caches',
			['warforged bronze'] = 'Excavation sites with warforged bronze caches',
			['fossilised bone'] = 'Excavation sites with fossilised bone caches',
			['yu biusk clay'] = 'Excavation sites with Yu\'biusk clay caches',
			['aetherium alloy'] = 'Excavation sites with aetherium alloy caches',
			['quintessence'] = 'Excavation sites with quintessence caches',
			['soapstone'] = 'Excavation sites with soapstone caches',
			['felt'] = 'Excavation sites with felt caches',
			['dragon metal'] = 'Excavation sites with dragon metal caches',
			['orgone'] = 'Excavation sites with orgone caches',
			['carbon black'] = 'Excavation sites with carbon black caches',
			['compass rose'] = 'Excavation sites with compass rose caches'
		},
		-- Added if the parameter has no content
		notdefined = {

		},
	}
	
	-- Run and add mapped categories
	for n, v in pairs(cat_map.defined) do
		if catargs[n] and catargs[n].one_defined then
			table.insert(ret,v)
		end
	end
	for n, v in pairs(cat_map.notdefined) do
		if catargs[n] and catargs[n].all_defined == false then
			table.insert(ret,v)
		end
	end

	-- combine table and format category wikicode
	for i, v in ipairs(ret) do
		if (v ~= '') then
			ret[i] = string.format('[[Category:%s]]', v)
		end
	end

	return table.concat(ret, '')
end

return p