Thread: castbar help
View Single Post
01-07-13, 11:05 AM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Try this out

Lua Code:
  1. local queued, casting
  2.  
  3. local OnEnter = function(self)
  4.     if(not casting) then
  5.         local castbar = YourPlayerFrame.Castbar
  6.         castbar:ClearAllPoints()
  7.         castbar:SetAllPoints(self.Health)
  8.     else
  9.         queued = self
  10.     end
  11. end
  12.  
  13. local OnHide = function()
  14.     local castbar = YourPlayerFrame.Castbar
  15.     castbar:ClearAllPoints()
  16.     castbar:SetAllPoints(YourPlayerFrame.Health)
  17. end
  18.  
  19. local CastStarted = function()
  20.     casting = true
  21. end
  22.  
  23. local CastEnded = function()
  24.     if(queued) then
  25.         OnEnter(queued)
  26.         queued = nil
  27.         casting = nil
  28.     else
  29.         OnHide()
  30.     end
  31. end
  32.  
  33. -- on the raid frames:
  34. -- Return the castbar if the unit disappears.
  35. self:HookScript('OnHide', OnHide)
  36. self:HookScript('OnEnter', OnEnter)
  37.  
  38. -- on the player frame:
  39. castbar.PostCastFailed = CastEnded
  40. castbar.PostCastInterrupted = CastEnded
  41. castbar.PostCastStop = CastEnded
  42. castbar.PostChannelStop = CastEnded
  43. castbar.PostCastStart = CastStarted
  44. castbar.PostChannelStart = CastStarted
  Reply With Quote