Kreiri

testing Inspect.Buff.Detail

Jul 9th, 2011
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.41 KB | None | 0 0
  1. -- RiftAddon.toc:
  2.  
  3. Identifier = "TestAddon"
  4. Name = "Test Addon"
  5. Description = "testing addon system"
  6. Author = "Kreiri"
  7. Version = "0.1"
  8. Environment = "1.3"
  9.  
  10. RunOnStartup = {
  11. "Libs/LibUnitChange/main.lua",
  12. "helpers.lua",
  13. "main.lua",
  14. }
  15.  
  16. -- helpers.lua:
  17.  
  18. if not tdump then tdump = function (t, s)
  19. local s = s or 0
  20. for i, v in pairs(t) do
  21. local kstring = string.rep(" ", s)
  22. if (type(i) == "number") then
  23. --kstring = kstring.."["..tostring(i).."] = "
  24. else
  25. kstring = kstring..tostring(i).." = "
  26. end
  27. if (type(v) == "table") then
  28. print(kstring.."{")
  29. tdump(v, s+1)
  30. print (string.rep(" ", s).."}")
  31. elseif (type(v) == "string") then
  32. print(kstring..'"'..v..'"')
  33. else
  34. print(kstring..tostring(v))
  35. end
  36. end
  37. end -- function tdump
  38. end
  39.  
  40. -- main.lua:
  41. local watchedunits = {["player"] = true,
  42. ["player.target"] = true,
  43. ["player.pet"] = true,
  44. ["focus"] = true}
  45.  
  46. local function OnUnitChange(units)
  47. print("---OnUnitChange---")
  48. print("Inspect.System.Time() = "..Inspect.System.Time())
  49. for unit, v in pairs(units) do
  50. if (watchedunits[unit] and v) then
  51. print("-----------------------")
  52. print(unit)
  53. local bufflist = Inspect.Buff.List(unit)
  54. if (bufflist) then
  55. local bufftable = Inspect.Buff.Detail(unit, bufflist)
  56. tdump(bufftable)
  57. end
  58. end
  59. end
  60. end
  61.  
  62. for unit, _ in pairs(watchedunits) do
  63. Library.UnitChange("TestAddon", {unit}, OnUnitChange)
  64. end
  65.  
  66. local function OnBuffAdd(unit, buffs)
  67. if watchedunits[Inspect.Unit.Lookup(unit)] then
  68. print("---OnBuffAdd---")
  69. print("Inspect.System.Time() = "..Inspect.System.Time())
  70. local bufftable = Inspect.Buff.Detail(unit, buffs)
  71. print("-----------------------")
  72. print(Inspect.Unit.Lookup(unit))
  73. tdump(bufftable)
  74. end
  75. end
  76. table.insert(Event.Buff.Add, {OnBuffAdd, "TestAddon", "OnBuffAdd"})
  77.  
  78. -- results:
  79.  
  80. 13:15:22: ---OnBuffAdd---
  81. 13:15:22: Inspect.System.Time() = 11613.955402158
  82. 13:15:22: -----------------------
  83. 13:15:22: player
  84. 13:15:22: b8000000022044713 = {
  85. 13:15:22: expired = 11630.55078125
  86. 13:15:22: remaining = 0
  87. 13:15:22: duration = 29.9453125
  88. 13:15:22: caster = "u0258800010FA3050"
  89. 13:15:22: icon = "Data/\UI\ability_icons\motif_of_tenacity.dds"
  90. 13:15:22: name = "Motif of Tenacity"
  91. 13:15:22: ability = "a000000004DB42B95"
  92. 13:15:22: }
  93. 13:15:25: ---OnUnitChange---
  94. 13:15:25: Inspect.System.Time() = 11617.164070553
  95. 13:15:25: -----------------------
  96. 13:15:25: player.target
  97. 13:15:25: b8000000022044713 = {
  98. 13:15:25: remaining = 26.7333984375
  99. 13:15:25: duration = 29.9453125
  100. 13:15:25: caster = "u0258800010FA3050"
  101. 13:15:25: icon = "Data/\UI\ability_icons\motif_of_tenacity.dds"
  102. 13:15:25: name = "Motif of Tenacity"
  103. 13:15:25: ability = "a000000004DB42B95"
  104. 13:15:25: }
  105. 13:15:25: b80000000220446D8 = {
  106. 13:15:25: expired = 112.908203125
  107. 13:15:25: remaining = 0
  108. 13:15:25: duration = 0
  109. 13:15:25: caster = "u0258800010FA3050"
  110. 13:15:25: icon = "Data/\UI\ability_icons\rudeawake1.dds"
  111. 13:15:25: name = "Rested"
  112. 13:15:25: noncancelable = true
  113. 13:15:25: }
  114. 13:15:25: b800000002204470E = {
  115. 13:15:25: caster = "u0258800010FA3050"
  116. 13:15:25: icon = "Data/\UI\ability_icons\surge_b.dds"
  117. 13:15:25: name = "Track Air Creatures"
  118. 13:15:25: ability = "a00000000289E1032"
  119. 13:15:25: }
Advertisement
Add Comment
Please, Sign In to add comment