Advertisement
OTG

GMCP Affliction tracker

OTG
Apr 10th, 2015
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. gmcpAff = gmcpAff or {}
  2.  
  3. local showAffMsg = true -- change to false if you don't want to see updates
  4.  
  5. local tblIgnore = {
  6. -- for afflictions we don't care about
  7. "blindness",
  8. "deafness",
  9. "insomnia",
  10. }
  11.  
  12. gmcpAffParse = function()
  13.  
  14. gmcpAff = {}
  15.  
  16. for k, v in pairs(gmcp.Char.Afflictions.List) do
  17. table.insert(gmcpAff,#gmcpAff+1,v["name"])
  18. end
  19.  
  20. gmcpAffShow()
  21. updateAffBox()
  22.  
  23. end
  24.  
  25.  
  26.  
  27. gmcpAffAdd = function()
  28.  
  29. local aff = gmcp.Char.Afflictions.Add.name
  30.  
  31. if not table.contains(gmcpAff,aff) then
  32. table.insert(gmcpAff,#gmcpAff+1,aff)
  33. end
  34.  
  35. if showAffMsg == true and not table.contains(tblIgnore, aff) then affEcho("Added "..aff) end
  36. updateAffBox()
  37.  
  38. end
  39.  
  40.  
  41. gmcpAffDel = function()
  42.  
  43.  
  44. local x = -1
  45.  
  46. local aff = gmcp.Char.Afflictions.Remove[1]
  47.  
  48. if table.contains(gmcpAff,aff) then
  49. for k, v in pairs(gmcpAff) do
  50. if aff == v then x = k end
  51. end
  52. end
  53.  
  54. if x > -1 then table.remove(gmcpAff,x) end
  55.  
  56. if showAffMsg == true and not table.contains(tblIgnore, aff) then affEcho("Cured "..aff) end
  57. updateAffBox()
  58.  
  59. end
  60.  
  61.  
  62. gmcpAffShow = function()
  63.  
  64. if #gmcpAff > 0 then
  65. cecho("<tomato>"..table.concat(gmcpAff,"<DarkSlateGrey>|<tomato>").."\n")
  66. end
  67.  
  68. end
  69.  
  70.  
  71. affEcho = function(line)
  72.  
  73. cecho("<SaddleBrown>[<pink>aff<SaddleBrown>]<white> "..line.."<reset>\n")
  74.  
  75. end
  76.  
  77.  
  78. function updateAffBox()
  79. --assumes your destination window is called AffBox
  80. clearUserWindow("AffBox")
  81. AffBox:cecho("<tomato> -- Afflictions --\n")
  82. AffBox:cecho("<white>"..table.concat(gmcpAff,"\n").."\n")
  83.  
  84. end
  85.  
  86. registerAnonymousEventHandler("gmcp.Char.Afflictions.Add","gmcpAffAdd")
  87. registerAnonymousEventHandler("gmcp.Char.Afflictions.Remove","gmcpAffDel")
  88. registerAnonymousEventHandler("gmcp.Char.Afflictions.List","gmcpAffParse")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement