Module:Skillname

-- local getArgs = require('Module:Arguments').getArgs local loader = require('Module:Loader')

local string, yesno, color = loader.require('String', 'Yesno', 'Color')

-- Converts Aliases into ID's local skills, aliases = loader.loadData('Skillname/Data', 'Skillname/Aliases')

local p = {}

function p.getSkillName(frame) local args = getArgs(frame) local skill = args[1] local valBefore = args[2] local isShort = yesno(args['short']) return p._getSkillName(skill, valBefore, isShort) end

function p.getSkillNameShort(frame) local args = getArgs(frame) local skill = args[1] local valBefore = args[2] return p._getSkillName(skill, valBefore, true) end

function p._getSkillName(skill, valBefore, isShort) checkType(1, skill, 'string') checkType(2, valBefore, { 'string', 'number'}, true) checkType(3, isShort, 'boolean', true) local oldSkill = skill local skill, tier = skill:match('^(.+) ([%divxIVX]+)$') skill = (skill or oldSkill):lower tier = string._toRoman(string._toArabic(tier)) skill = skill:lower:gsub('_', ' ') skill = aliases[skill] or skill local skill = skills[skill] if not skill then return string.error('Invalid Skill name %q', skill) end return string.wrapHtml{ {			string.makeImage(				skill.icon,				{					size = skill.size or '24x24px',					link = skill.name,				}			), string.wrapHtml{ ' ', ' ', { class = 'font-initial' } }, string.makeLink(skill.name, string.wrapHtml{ {					skill[isShort and 'nameshort' or 'name'],					tier ~= 0 and ' ' .. tier or ''				}, ' ', {					class = "hsw-gamefont",					style = {						color = skill.color					}				}			}), valBefore and ' ' or '', valBefore and string.wrapHtml(valBefore, 'font', {style={color=skill.color}}) or '', },		' ', {			class = 'txt-nowrap'; }	} end

-- Template: Skill XP

function p.skillXP (frame) local args = getArgs(frame) local str = args[1] return p._skillXP(str) end

function p._skillXP(str) checkType(1, str, 'string') str = str:gsub('[%[%],]', '') local num, skill, isPercent if str:match('%+?(%d[%d%.%-]*)(%%?)%s(.*)') then isPercent = str:match('(%%)') num, skill = str:match('%+?(%d[%d%.%-]*)%%?%s(.*)') else return string.error('Invalid syntax %q', str) end skill = skill:gsub('%sXP$', '') return table.concat{ color.colorText('Green', '+' .. (str:find("%-") and num or string._formatNum(num)) .. (isPercent and '%' or '')), ' ',		p._getSkillName(skill, 'XP'), } end

return p