Module:SCP

From Roat Pkz
Jump to navigation Jump to search

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

-- <pre>

local p = {}

local pics = {
	diary = { image = 'Achievement Diaries icon', link = '' },
	combatachievement = { image = 'Combat achievements', link = '' },
	combat = { image = 'Attack style icon', link = '' },
	combatstyle = { image = 'Attack style icon', link = '' },
	dd = { image = 'Distraction & Diversion icon', link = '' },
	favour = { image = 'Kourend Favour icon', link = '' },
	minigame = { image = 'Minigame icon', link = '' },
	music = { image = 'Music', link = 'Music' },
	quest = { image = 'Quest point icon', link = '' },
	raid = { image = 'Raids icon', link = '' },
	overall = { image = 'Stats icon', link = '' },
	total = { image = 'Stats icon', link = '' },
	time = { image = 'Watch', link = '' },
	agility = { image = 'Agility icon', link = 'Agility' },
	attack = { image = 'Attack icon', link = '' },
	construction = { image = 'Construction icon', link = '' },
	cooking = { image = 'Cooking icon', link = 'Cooking' },
	crafting = { image = 'Crafting icon', link = 'Crafting' },
	defence = { image = 'Defence icon', link = '' },
	farming = { image = 'Farming icon', link = 'Farming' },
	firemaking = { image = 'Firemaking icon', link = 'Firemaking' },
	fishing = { image = 'Fishing icon', link = 'Fishing' },
	fletching = { image = 'Fletching icon', link = 'Fletching' },
	herblore = { image = 'Herblore icon', link = 'Herblore' },
	hitpoints = { image = 'Hitpoints icon', link = '' },
	hunter = { image = 'Hunter icon', link = 'Hunter' },
	magic = { image = 'Magic icon', link = '' },
	mining = { image = 'Mining icon', link = 'Mining' },
	prayer = { image = 'Prayer icon', link = '' },
	ranged = { image = 'Ranged icon', link = '' },
	runecraft = { image = 'Runecraft icon', link = 'Runecraft' },
	sailing = { image = 'Sailing icon', link = '' },
	slayer = { image = 'Slayer icon', link = 'Slayer' },
	smithing = { image = 'Smithing icon', link = 'Smithing' },
	strength = { image = 'Strength icon', link = '' },
	summoning = { image = 'Summoning icon', link = 'Summoning' },
	thieving = { image = 'Thieving icon', link = 'Thieving' },
	warding = { image = 'Warding icon', link = 'Warding' },
	woodcutting = { image = 'Woodcutting icon', link = 'Woodcutting' }
}

function getSkillInformation(skill)
	local file
	if type(skill) == 'string' and pics[skill:lower()] then
		file = pics[skill:lower()]
	else
		file = pics.overall
	end
	
	local image = string.format('[[File:%s.png|21x21px|link=%s|alt=%s]]', file.image, file.link or '', file.link or '')
	
	return { image = image, link = file.link }
end

function p.main(frame)
	local args = frame:getParent().args
	local skill = args[1] or ''
	local level = args[2]
	local sort = args.sort
	local link = args.link
	
	return p._main(skill, level, link, sort)
end

function p._main(skill, level, link, sort)
	local skillInfo = getSkillInformation(skill)
	
	if level then
		return string.format('%s<span class="scp" data-skill="%s" data-level="%s">%s %s %s</span>', sort and string.format('data-sort-value="%s"|', level) or '', skillInfo.link, level, skillInfo.image, level, link and string.format('[[%s]]', skillInfo.link) or '')
	else
		return string.format('%s %s', skillInfo.image, link and string.format('[[%s]]', skillInfo.link) or '')
	end
end

return p