Module:Skillname

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

local string, table, yesno, color = loader.require('String', 'Table', '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] return p._getSkillName(skill, {		isShort = args.isShort,		textOnly = args.textOnly,		iconOnly = args.iconOnly	}) end

function p.getSkillNameShort(frame) local args = getArgs(frame) local skill = args[1] return p._getSkillName(skill, {		isShort = true,		textOnly = args.textOnly,		iconOnly = args.iconOnly	}) end

function p._getSkillName(skill, opts) checkType(1, skill, 'string') local isShort, textOnly, iconOnly = opts.isShort, opts.textOnly, opts.iconOnly 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 local out = {} if not yesno(textOnly, false) then table.push(out, string.makeImage( skill.icon, {				size = skill.size or '24x24px', link = skill.name, }		))	end if not yesno(iconOnly, false) then table.push(out, string.makeLink(skill.name, string.wrapHtml{ { skill[yesno(isShort, false) and 'nameshort' or 'name'], tier ~= 0 and ' ' .. tier or '' }, ' ', {				class = 'hsw-gamefont', style = { color = skill.color }			}		}))	end return string.wrapHtml{ table.concat(out, string.wrapHtml{ ' ', ' ', { class = 'font-initial' } }), ' ', {			class = 'txt-nowrap'; }	} end

-- Template: Skill XP

function p.skillXP (frame) local args = getArgs(frame) return p._skillXP(args[1], {		iconOnly = args.iconOnly,		textOnly = args.textOnly,		isShort = args.isShort	}) end

function p._skillXP(str, opts) 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, opts), } end

return p