Module:Skillname

-- local loadLib = require('Module:LoadLib') local loader = require('Module:Loader') loadLib(_G, {	onmain = { 'Module:Mainonly', field='on_main' }, })

local p = {}

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

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{ ' ', ' ', { style = 'font-family:initial;' } }, string.makeLink(skill.name, string.wrapHtml{ {					skill[isShort and 'nameshort' or 'name'],					tier ~= 0 and ' ' .. tier or ''				}, ' ', {					style = {						color = skill.color					}				}			}), valBefore and ' ' or '', valBefore and string.wrapHtml(valBefore, 'font', {style={color=skill.color}}) or '', },		' ', {			style = 'whitespace: no-wrap;'; }	} 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 if str:match('%+?(%d[%d%.]*)%s(.*)') then num, skill = str:match('%+?(%d[%d%.]*)%s(.*)') else return string.error('Invalid syntax %q', str) end skill = skill:gsub('%sXP$', '') return table.concat{ colorText('Green', '+'..string._formatNum(num)), ' ',		p._getSkillName(skill, 'XP'), } end

return p