Module:Infobox Thieving

From WIDEVERSE Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:Infobox Thieving/doc

local p = {}

local yesno = require('Module:Yesno')
local ns = mw.title.getCurrentTitle().nsText
local pgTitle = mw.title.getCurrentTitle().text

local _thvimg = '[[File:Thieving-icon.png|link=Thieving|frameless|20px]]'
local _aglimg = '[[File:Agility-icon.png|link=Agility|frameless|20px]]'

local switchfo = require('Module:Switchfobox multi')

-- Params list for Switchfobox
local infobox_params = {
	'version',
	'lvl',
	'xp',
	'respawn',
	'multiloot',
	'stun',
	'damage',
	'guards',
	'loot',
	'name',
	'image',
	'location',
	'quest',
	'nosmw'
}

-- Used to determine single or multi boxes
function p.main(frame)
	local args = frame:getParent().args
	local ret_module
	if args['version1'] then
		--has multiple
		return switchfo.make_boxes( args, infobox_params, 'Databox Thieving single' )
	else
		--single
		return p.single(frame)
	end
end

-- Creates a single databox
function p.single(frame)
	local args = frame:getParent().args

	local multiloot = yesno(args.multiloot) or false
	local lvl = numberargs(args.lvl,'lvl') or 'Unknown'
	local lvl_disp = lvl..'  '.._thvimg
	local xp = numberargs(args.xp, 'xp') or 'Unknown'
	local xp_disp = xp..'  XP'
	local respawn = numberargs(args.respawn, 'respawn')
	local respawn_disp = timearg(respawn, 'respawn')
	local stun = numberargs(args.stun, 'stun')
	local damage = stringargs(args.damage, 'damage')
	local stun_disp = timearg(stun, 'stun')..'  /  '..damage
	local loot = args.loot or '[[#|? (edit)|action=edit]]'
	-- For generated versions
	local name = args.name
	local image = stringargs(args.image, 'image')
	local location = stringargs(args.location, 'location')
	local quest = stringargs(args.quest, 'quest')
	-- Version (for smw subobject)
	local version = args.version

	local dbloot, tploot, qdloot
	if multiloot then
		dbloot = lootlvl(lvl, 10)
		trloot = lootlvl(lvl, 20)
		qdloot = lootlvl(lvl, 30)
	end
	
	local guardsTbl, guards = {}
	if type(args.guardstable) == 'table' then
		guardsTbl = args.guardstable
		guards = mw.text.listToText(guardsTbl, ', ', ', ')
	elseif args.guards then
		for v in args.guards:gmatch('([^,]+)') do
			v = '[['..v..']]'
			table.insert(guardsTbl, v)
		end
		guards = mw.text.listToText(guardsTbl, ', ', ', ')
	end

	if string.match(loot, '<tr class="nonmembers%-item%s*"') or  string.match(loot, '<tr class="members%-item%s*"') then
		local dropHead = mw.getCurrentFrame():expandTemplate{title='DropsTableHead'}
		local dropFoot = mw.getCurrentFrame():expandTemplate{title='DropsTableBottom'}
		loot = dropHead..loot..dropFoot
	end

	local t = mw.html.create('table')
	if not name then
		t:addClass('wikitable infobox-thieving')
		:css('text-align','center')
		if respawn then
			t:tag('tr')
				:tag('th'):wikitext('Thieving level'):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('td'):wikitext(xp_disp):done()	
				:tag('th'):wikitext('Respawn time'):done()
				:tag('td'):wikitext(respawn_disp):done()
			:done()
		elseif stun then
			t:tag('tr')
				:tag('th'):wikitext('Thieving level'):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('td'):wikitext(xp_disp):done()	
		 		:tag('th'):wikitext('Stun time / damage'):done()
		 		:tag('td'):wikitext(stun_disp):done()
		 	:done()
		else
			t:tag('tr')
				:tag('th'):wikitext('Thieving level'):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('td'):wikitext(xp_disp):done()	
				:tag('td'):attr('colspan',2):wikitext('<span title="Please enter a stun time and damage or respawn time" style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">ERROR</span>'):done()
			:done()
		end
		if multiloot then
			t:tag('tr')
				:tag('th'):wikitext('Double loot'):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('td'):wikitext(trloot):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('td'):wikitext(qdloot):done()
			:done()
		end
		if guards then
			t:tag('tr')
				:tag('th'):wikitext('Guarded by'):done()
				:tag('td'):attr('colspan',5):wikitext(guards):done()
			:done()
		end
		t:tag('tr')
			:tag('th'):attr('colspan',6):wikitext('Loot'):done()
		:done()
		:tag('tr')
			:tag('td'):attr('colspan',6):addClass('thvloot-cell'):wikitext(loot):done()
		:done()
	-- Version with name, location etc
	else
		t:addClass('wikitable')
		:css('text-align','center')
		if multiloot and respawn and guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Respawn time'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(respawn_disp):done()
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',4):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',4):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif multiloot and respawn then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Respawn time'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(respawn_disp):done()
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif multiloot and stun and guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Stun time / damage'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(stun_disp):done()
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',4):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',4):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif multiloot and stun then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Stun time / damage'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(stun_disp):done()
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif multiloot and guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('td'):attr('rowspan',2):wikitext('<span title="Please enter a stun time and damage or respawn time" style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">ERROR</span>'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',4):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',4):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif multiloot then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Double loot'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(dbloot):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Triple loot'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(trloot):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('td'):attr('rowspan',2):wikitext('<span title="Please enter a stun time and damage or respawn time" style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">ERROR</span>'):done()
				:tag('th'):wikitext('Quadruple loot'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(qdloot):done()
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif  respawn and guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Respawn time'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(respawn_disp):done()
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',3):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',3):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif respawn then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Respawn time'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(respawn_disp):done()
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif stun and guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Stun time / damage'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(stun_disp):done()
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',3):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',3):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif stun then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Stun time / damage'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(stun_disp):done()
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		elseif guards then
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('td'):attr('rowspan',2):wikitext('<span title="Please enter a stun time and damage or respawn time" style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">ERROR</span>'):done()
				:tag('th'):wikitext('Guarded by'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(guards):done()
			:done()
			:tag('tr')
				:tag('th'):attr('colspan',3):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):attr('colspan',3):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		else
			t:tag('tr')
				:tag('th'):wikitext(name):done()
				:tag('th'):wikitext('Thieving level'):done()
				:tag('th'):wikitext('Location'):done()
			:done()
			:tag('tr')
				:tag('th'):attr('rowspan',5):wikitext(image):done()
				:tag('td'):wikitext(lvl_disp):done()
				:tag('td'):wikitext(location):done()
			:done()
			:tag('tr')
				:tag('th'):wikitext('Thieving XP'):done()
				:tag('th'):wikitext('Quest'):done()
			:done()
			:tag('tr')
				:tag('td'):wikitext(xp_disp):done()
				:tag('td'):wikitext(quest):done()
			:done()
			:tag('tr')
				:tag('td'):attr('rowspan',2):wikitext('<span title="Please enter a stun time and damage or respawn time" style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">ERROR</span>'):done()
				:tag('th'):wikitext('Loot'):done()
			:done()
			:tag('tr')
				:tag('td'):addClass('thvloot-cell'):wikitext(loot):done()
			:done()
		end
	end

	-- SMW
	--[[This needs to be reworked as soon as infoboxes and databoxes support switching and subobjects]] --
	local nosmw = args.nosmw or false
	if ns == '' and not nosmw then
		local smwData = {['Thieving level'] = lvl, ['Thieving xp'] = xp, ['Loot respawn'] = respawn, ['Multiloot'] = multiloot, ['Stun time'] = stun, ['Stun damage'] = damage,}
		if not version then
			local versions
			local variants = mw.smw.ask({'[[Is variant of::'..pgTitle..']]','?#-'})
			if not variants then
				versions = tostring(pgTitle) -- Data to page, has no variant subobjects
			else
				versions = {}
				for _,v in ipairs(variants) do
					local subobj = tostring(v[1])
					subobj = string.gsub(subobj:match('%#[%w%s_%(%)]+$'), '%#', '')
					table.insert(versions, subobj) -- Only add subobject name
				end
			end
			if type(versions) == 'string' then
				smwData['All Thieving level'] = lvl -- Add "All Thieving level" property
				mw.smw.set(smwData) -- Add data to page
			else
				for _,v in ipairs(versions) do
					mw.smw.set({['All Thieving level'] = lvl}) -- Add theiving lvl to "All Thieving level" of Object/Page
					mw.smw.subobject(smwData, v) -- Add data to version subobjects
				end
			end
		elseif type(version) == 'string' then
			local versClean = string.gsub(string.sub(version,0,5), '%.', '')..string.sub(version,6)
			-- In case NPC variants don't exist, assign them members status and child of
			local smwVersion = mw.smw.ask({'[['..versClean..']]','?Is members only','?Is variant of'})
			local smwNPC = mw.smw.ask({'[['..pgTitle..']]','?Is members only'})
			smwData['Is members only'] = smwVersion['Is members only'] or smwNPC['Is members only'] or false
			smwData['Is variant of'] = smwVersion['Is variant of'] or pgTitle
			mw.smw.set({['All Thieving level'] = lvl}) -- Add theiving lvl to "All Thieving level" of Object/Page
			mw.smw.subobject(smwData, versClean)
		end
	end

	local cats = '[[Category:Thievable entities]]'
	if ns == '' then
		t:wikitext(cats):done()
	end

	return t
end

-- For numerical args
function numberargs(arg,argname)
	local arg_v = (arg or ''):find('%S') and string.gsub(arg,',','') or -1
	local arg_i
	if arg_v == -1 then
		arg_i = nil
	elseif string.lower(arg_v) == 'unknown' then
		arg_i = 'Unknown'
	elseif string.lower(arg_v) == 'n/a' then
		arg_i = 'N/A'
	elseif string.lower(arg_v) == 'varies' then
		arg_i = 'Varies'
	else
		arg_i = tonumber(arg_v:gsub(',',''),10)
		if not arg_i then
			arg_i = badarg(argname,'should be a single numerical value.')
		end
	end
	return arg_i
end

-- For times
function timearg(arg, argname)
	local arg = tonumber(arg)
	if not arg or arg%1 ~= 0 then
		return badarg(argname,'should be an integer number representing game ticks.')
	end
	local mins = 0
	local secs = arg*0.6
	while arg > 99 do
		mins = mins+1
		arg = arg-100
		secs = arg*0.6
	end
		
	local disptime = secs
	if mins<1 then
		disptime = secs .. "s"
	else --mins > 0
		if secs < 1 then
			disptime = mins .. "m"
		else --secs > 0
			disptime = mins .. "m "	.. secs .. "s"
		end
	end

	return disptime
end

-- For strings
function stringargs(arg, argname)
	local ret
	if not arg then
		ret = '[[#|? (edit)|action=edit]]'
	elseif type(arg) ~= 'string' then
		return badarg(argname, 'must be a string.')
	else
		ret = string.match(arg or '','%S') and arg or '[[#|? (edit)|action=edit]]'
	end
	return ret
end

-- For double, tripple, quadruple loot
function lootlvl(lvl, loot)
	loot = tonumber(loot)
	if lvl and loot then
		local thiev = lvl + loot
		if thiev > 99 then
			return '-'
		end
		local agil = lvl + loot - 10
		local rett = tostring(thiev)..'  '.._thvimg..'<br />'..tostring(agil)..'  '.._aglimg
		rett = mw.getCurrentFrame():preprocess(rett)
		return rett
	else
		return nil
	end
end

-- red ERR span with title hover for explanation
function badarg(argname, argmessage)
	return '<span '..
			'title="The parameter «'..argname..'» '..argmessage..'" '..
			'style="color:red; font-weight:bold; cursor:help; border-bottom:1px dotted red;">'..
			'ERR</span>'
end

return p