Module:SkillPic: Difference between revisions

From Guinea Isles Wiki
Created page with "local p = {} local pics = { vigour = { image = "Skill Vigour", link = "Vigour" }, melee = { image = "Skill Melee", link = "Melee" }, forestry = { image = "Skill Forestry", link = "Forestry" }, fishing = { image = "Skill Fishing", link = "Fishing" }, farming = { image = "Skill Farming", link = "Farming" }, cooking = { image = "Skill Cooking", link = "Cooking" }, excavation = { image = "Skill Excavation", link = "Excavation" }, s..."
 
No edit summary
Line 49: Line 49:


local image = string.format(
local image = string.format(
'[[File:%s.png|link=%s|alt=%s]]', file.image, file.link or '', file.link or '')
'[[File:%s.png|link=%s|alt=%s|32x32px]]', file.image, file.link or '', file.link or '')
return { image = image, link = file.link }
return { image = image, link = file.link }

Revision as of 14:33, 21 September 2025

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

local p = {}

local pics = {
	vigour = {
		image = "Skill Vigour",
		link = "Vigour"
	},
	melee = {
		image = "Skill Melee",
		link = "Melee"
	},
	forestry = {
		image = "Skill Forestry",
		link = "Forestry"
	},
	fishing = {
		image = "Skill Fishing",
		link = "Fishing"
	},
	farming = {
		image = "Skill Farming",
		link = "Farming"
	},
	cooking = {
		image = "Skill Cooking",
		link = "Cooking"
	},
	excavation = {
		image = "Skill Excavation",
		link = "Excavation"
	},
	smithing = {
		image = "Skill Smithing",
		link = "Smithing"
	},
	crafting = {
		image = "Skill Crafting",
		link = "Crafting"
	},
}

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|link=%s|alt=%s|32x32px]]', file.image, file.link or '', file.link or '')
	
	return { image = image, link = file.link }
end


function p._main(skill, level, link)
	local skillInfo = getSkillInformation(skill)
	local img_align_style = "position:relative;display:inline-block;height:1em;"
	if level then
		return string.format('<span class="scp" data-skill="%s" data-level="%s" style="%s">%s %s %s</span>',
			skillInfo.link,
			level,
			img_align_style,
			skillInfo.image,
			level,
			link and string.format('[[%s]]', skillInfo.link) or '')
	else
		return string.format('<span class="scp" data-skill="%s" style="%s">%s %s</span>',
			skillInfo.link,
			img_align_style,
			skillInfo.image,
			link and string.format('[[%s]]', skillInfo.link) or '')
	end

end

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

return p