KnownScanner.lua 801 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. local myname, ns = ...
  2. local function IsKnown(link)
  3. ns.scantip:SetHyperlink(link)
  4. for i=1,ns.scantip:NumLines() do
  5. if ns.scantip.L[i] == ITEM_SPELL_KNOWN then return true end
  6. end
  7. end
  8. ns.knowns = setmetatable({}, {
  9. __index = function(t, i)
  10. local id = ns.ids[i]
  11. if not id then return end
  12. if IsKnown(i) then
  13. t[i] = true
  14. return true
  15. end
  16. end
  17. })
  18. -- "Requires Previous Rank"
  19. local PREV_RANK = TOOLTIP_SUPERCEDING_SPELL_NOT_KNOWN
  20. local function NeedsRank(link)
  21. ns.scantip:SetHyperlink(link)
  22. for i=1,ns.scantip:NumLines() do
  23. if ns.scantip.L[i] == PREV_RANK then return true end
  24. end
  25. end
  26. ns.unmet_requirements = setmetatable({}, {
  27. __index = function(t, i)
  28. local id = ns.ids[i]
  29. if not id then return end
  30. if NeedsRank(i) then
  31. t[i] = true
  32. return true
  33. end
  34. end
  35. })