Advertisement
Kreiri

testing Inspect.Buff.Detail

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