Module:SCP

From Roat Pkz
Revision as of 19:30, 23 March 2024 by Hefner (talk | contribs) (1 revision imported)
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 = 'Achievement Diary' },
	combatachievement = { image = 'Combat achievements', link = 'Combat Achievements' },
	combat = { image = 'Attack style icon', link = 'Combat level' },
	combatstyle = { image = 'Attack style icon', link = 'Combat styles' },
	dd = { image = 'Distraction & Diversion icon', link = 'Distractions and Diversions' },
	favour = { image = 'Kourend Favour icon', link = 'Kourend Favour' },
	minigame = { image = 'Minigame icon', link = 'Minigames' },
	music = { image = 'Music', link = 'Music' },
	quest = { image = 'Quest point icon', link = 'Quest points' },
	raid = { image = 'Raids icon', link = 'Raids' },
	overall = { image = 'Stats icon', link = 'Skills' },
	total = { image = 'Stats icon', link = 'Total level' },
	time = { image = 'Watch', link = 'Time' },
	agility = { image = 'Agility icon', link = 'Agility' },
	attack = { image = 'Attack icon', link = 'Attack' },
	construction = { image = 'Construction icon', link = 'Construction' },
	cooking = { image = 'Cooking icon', link = 'Cooking' },
	crafting = { image = 'Crafting icon', link = 'Crafting' },
	defence = { image = 'Defence icon', link = 'Defence' },
	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 = 'Hitpoints' },
	hunter = { image = 'Hunter icon', link = 'Hunter' },
	magic = { image = 'Magic icon', link = 'Magic' },
	mining = { image = 'Mining icon', link = 'Mining' },
	prayer = { image = 'Prayer icon', link = 'Prayer' },
	ranged = { image = 'Ranged icon', link = 'Ranged' },
	runecraft = { image = 'Runecraft icon', link = 'Runecraft' },
	sailing = { image = 'Sailing icon', link = 'Sailing' },
	slayer = { image = 'Slayer icon', link = 'Slayer' },
	smithing = { image = 'Smithing icon', link = 'Smithing' },
	strength = { image = 'Strength icon', link = 'Strength' },
	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