Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 1.13 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function parseSkills()
  2.         if not gmcp.Char.Skills then
  3.                 sendGMCP("Char.Skills.Get")
  4.         return
  5.         end
  6.  
  7.         ksys.temp.skills = {}
  8.  
  9.         for i,v in ipairs(gmcp.Char.Skills.Groups or {}) do
  10.                 local skill = gmcp.Char.Skills.Groups[i]
  11.                 local rank = skill.rank:match("^%w+")
  12.                 local percent = skill.rank:match("(%d+)%%$")
  13.                 ksys.temp.skills[skill.name] = {rank, tonumber(percent) or 0}
  14.         end
  15. end
  16.  
  17. function canUse(skill, rankRequired, percentRequired)
  18.         parseSkills()
  19.  
  20.         if ksys.temp.skills[skill] then
  21.                 if (getSkillrankValue(ksys.temp.skills[skill][1]) > getSkillrankValue(rankRequired))
  22.                         or
  23.                         (getSkillrankValue(ksys.temp.skills[skill][1]) == getSkillrankValue(rankRequired)
  24.                         and ksys.temp.skills[skill][2] >= percentRequired)
  25.                 then
  26.                         return true
  27.                 end
  28.         end
  29.  
  30.         return false
  31. end
  32.  
  33. function getSkillrankValue(skillrank)
  34.         ksys.temp.skillranks = {"Inept",
  35.                 "Novice",
  36.                 "Apprentice",
  37.                 "Capable",
  38.                 "Adept",
  39.                 "Skilled",
  40.                 "Gifted",
  41.                 "Expert",
  42.                 "Virtuoso",
  43.                 "Fabled",
  44.                 "Mythical",
  45.                 "Transcendent"}
  46.  
  47.         for i,v in pairs(ksys.temp.skillranks) do
  48.                 if v:lower() == skillrank:lower() then
  49.                         return i
  50.                 end
  51.         end
  52.         return 0
  53. end