Advertisement
Guest User

emeral

a guest
Oct 25th, 2009
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. function BasicUnitFrames_Button_OnLoad(self)
  2.     self:RegisterForDrag("LeftButton")
  3.     self:RegisterEvent("UNIT_HEALTH")
  4.     self:RegisterEvent("UNIT_MAXHEALTH")
  5.     self.healthbar = getglobal(self:GetName().."_HealthBar")
  6.     self.name = getglobal(self.GetName().."_Name")
  7. end
  8.  
  9. function BasicUnitFrames_Button_OnShow(self)
  10.     local unit = self.GetAttribute("unit")
  11.     if unit then
  12.         self.name:SetText(UnitName(unit))
  13.         local class = select(2, UnitClass(unit)) or "WARRIOR"
  14.         local color = RAID_CLASS_COLORS[class]
  15.         self.healthbar:SetStatusBarColor(color.r, color.g, color.b)
  16.     end
  17. end
  18.    
  19. function BasicUnitFrames_Button_OnEvent(self, event, ...)
  20.     local unit = ...
  21.     if self:GetAttribute("unit") == unit then
  22.         if event == "UNIT_MAXHEALTH" then
  23.             self.healthbar:SetMinMaxValues(0, UnitHealthMax(unit))
  24.             self.healthbar:SetValue(UnitHealth(unit))
  25.         elseif event == "UNIT_HEALTH" then
  26.             self.healthbar:SetValue(UnitHealth(unit))
  27.         end
  28.     end
  29. end
  30.  
  31. function BasicUnitFrames_Button_OnDragStart(self, button)
  32.     BasicUnitFrames_Header:StartMoving()
  33.     BasicUnitFrames_Header:StopMovingOrSizing()
  34. end
  35.  
  36. function BasicUnitFrames_Button_OnDragStop(self, button)
  37.     if BasicUnitFrames_Header.isMoving then
  38.         BasicUnitFrames_Header:StopMovingOrSizing()
  39.     end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement