Thread: Altpower
View Single Post
12-06-11, 02:06 AM   #4
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Originally Posted by Haleth View Post
Specify? It works fine for me.
It didn't work at all in Firelands for me yestoday and it was working fine untill patch.

My script same as Smelly's Altpower/Tukui

LUA Code:
  1. if AftermathhUI.plugins.altpower == false then return end
  2.  
  3. _G["PlayerPowerBarAlt"]:UnregisterEvent("UNIT_POWER_BAR_SHOW")
  4. _G["PlayerPowerBarAlt"]:UnregisterEvent("UNIT_POWER_BAR_HIDE")
  5. _G["PlayerPowerBarAlt"]:UnregisterEvent("PLAYER_ENTERING_WORLD")
  6.  
  7. local AltPowerBG = CreateFrame("Frame", "AltPowerBG", frame)
  8. AltPowerBG:SetSize(200, 24)
  9. AltPowerBG:SetPoint('BOTTOMLEFT', UIParent, 199, 211)
  10. AltPowerBG:SetBackdrop({
  11.     bgFile = AftermathhUI.media.blank,
  12.     insets = {top = 1, left = 4.5, bottom = 1, right = 1},
  13. })
  14. AltPowerBG:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  15.  
  16. local AltPowerBar = CreateFrame("StatusBar", "AltPowerBar", AltPowerBG)
  17. AltPowerBar:SetStatusBarTexture(AftermathhUI.media.texture)
  18. AltPowerBar:SetPoint("TOPLEFT", AltPowerBG, "TOPLEFT", 2, -2)
  19. AltPowerBar:SetMinMaxValues(0, 100)
  20. AltPowerBar:SetPoint("BOTTOMRIGHT", AltPowerBG, "BOTTOMRIGHT", -2, 2)
  21.  
  22. CreateBorderLight(AltPowerBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 2)
  23.  
  24. local AltPowerText = AltPowerBar:CreateFontString(nil, "OVERLAY")
  25. AltPowerText:SetFont(AftermathhUI.media.font, 13, AftermathhUI.media.fontflag)
  26. if AftermathhUI.media.shadowoffset == true then
  27.     AltPowerText:SetShadowColor(0, 0, 0)
  28.     AltPowerText:SetShadowOffset(1, -1)
  29. end
  30. AltPowerText:SetPoint("CENTER", AltPowerBG, "CENTER")
  31.  
  32. AltPowerBG:RegisterEvent("UNIT_POWER")
  33. AltPowerBG:RegisterEvent("UNIT_POWER_BAR_SHOW")
  34. AltPowerBG:RegisterEvent("UNIT_POWER_BAR_HIDE")
  35. AltPowerBG:RegisterEvent("PLAYER_ENTERING_WORLD")
  36. AltPowerBG:SetScript("OnEvent", function(self)
  37.     self:UnregisterEvent("PLAYER_ENTERING_WORLD")
  38.     if UnitAlternatePowerInfo("player") or UnitAlternatePowerInfo("target") then
  39.         self:Show()
  40.     else
  41.         self:Hide()
  42.     end
  43. end)
  44.  
  45. local TimeSinceLastUpdate = 1
  46. AltPowerBar:SetScript("OnUpdate", function(self, elapsed)
  47.     if not AltPowerBar:IsShown() then return end
  48.     TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
  49.  
  50.     if (TimeSinceLastUpdate >= 1) then
  51.         self:SetMinMaxValues(0, UnitPowerMax("player", ALTERNATE_POWER_INDEX))
  52.         local power = UnitPower("player", ALTERNATE_POWER_INDEX)
  53.         local mpower = UnitPowerMax("player", ALTERNATE_POWER_INDEX)
  54.         self:SetValue(power)
  55.         AltPowerText:SetText(power.." / "..mpower)
  56.         local r, g, b = AftermathhUI.ColorGradient(power/mpower, 0,.8,0,.8,.8,0,.8,0,0)
  57.         AltPowerBar:SetStatusBarColor(r, g, b)
  58.         self.TimeSinceLastUpdate = 0
  59.     end
  60. end)

Last edited by Aftermathhqt : 12-06-11 at 02:32 AM.
  Reply With Quote