Module documentation
This documentation is transcluded from Module:SCP/doc. [edit] [history] [purge]
Module:SCP's function main is invoked by Template:SCP.

This module is a helper module to be used by other modules; it may not designed to be invoked directly. See RuneScape:Lua/Helper modules for a full list and more information. For a full list of modules using this helper click here

FunctionTypeUse
_main(skill, level, link, sort)StringTakes inputs and gives outputs like Template:SCP. See the template documentation for more info.

-- <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