Module:Skill

-- (prevents literal interpretation of links or categories within the module code) -- Lua Templating for Skill related displays local p = {} local cargo = mw.ext.cargo

-- Usage: function p.Tooltip(frame) local where = 'Name="%s"' local param = frame.args[1] if frame.args['Id'] and frame.args['Id'] ~= '' then where = 'SkillIds HOLDS "%s"' param = frame.args['Id'] elseif frame.args['Name'] and frame.args['Name'] ~= '' then param = frame.args['Name'] elseif tonumber(frame.args[1]) ~= nil then where = 'SkillIds HOLDS "%s"' end local fields = '_pageName=Link,Name,MaxSkillLevel,SkillLv1IconName,'.. 'Sp,SPLv2,SPLv3,SPLv4,Description1,Description2,Description3,Description4' local skill = cargo.query('Skills', fields, {   where = string.format(where, param),    limit = 1,  })[1] if skill == nil then return 'None' end

local descTemplate = "  Lv. %d : %s [%s SP]" local descriptions = { string.format(" Lv. 1 : %s [%s SP]", skill['Description1'], skill['Sp']) } for i=2,4 do    if tonumber(skill['MaxSkillLevel']) < i then break end descriptions[#descriptions+1] = string.format(   	descTemplate, i, skill['Description'..i],  skill['SPLv'..i]) end return frame:expandTemplate{title='TooltipLong', args={ string.format(' %s',       skill['SkillLv1IconName'], skill['Link'], skill['Link'], skill['Name']), table.concat(descriptions) }} end

return p --