View Single Post
11-10-14, 11:05 AM   #6
Aftermathhqt
A Molten Giant
 
Aftermathhqt's Avatar
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 784
Red face

Originally Posted by Rilgamon View Post
While I cant answer your question I recommend you clean up first
You're still creating new functions per update. Move all definitions out of your update function.
And only put stuff in there you need to update.
Okay, well the update still doesn't have any effect. I really can't figure why doh.


Lua Code:
  1. local Current, Max = UnitXP("player"), UnitXPMax("player")
  2. local CurLvl = UnitLevel("player")
  3. local Rested = GetXPExhaustion()
  4. local IsRested = GetRestState()
  5.  
  6. local Experience = CreateFrame("Frame", nil, UIParent)
  7.  
  8. local ExperienceBar = CreateFrame('StatusBar', nil, UIParent)
  9. local ExperienceBarRested = CreateFrame('StatusBar', nil, UIParent)
  10.  
  11. local InvisFrame = CreateFrame("Frame", nil, ExperienceBar)
  12. InvisFrame:SetFrameStrata("HIGH")
  13. InvisFrame:SetFrameLevel(5)
  14. InvisFrame:SetAllPoints()
  15.  
  16. local ExperienceFont = InvisFrame:CreateFontString(nil, 'OVERLAY') 
  17.  
  18. local function UpdateExp() 
  19.    
  20.     ExperienceBar:SetMinMaxValues(0, Max)
  21.     ExperienceBar:SetValue(Current)
  22.    
  23.     if (IsRested == 1 and Rested) then     
  24.         ExperienceBarRested:SetMinMaxValues(0, Max)
  25.         ExperienceBarRested:SetValue(Rested + Current)
  26.         ExperienceFont:SetText(""..Current.." / "..Max.."("..Rested..")")
  27.     else
  28.         ExperienceBar:SetValue(0)
  29.         ExperienceFont:SetText(""..Current.." / "..Max.."")
  30.     end
  31. end
  32.  
  33. ExperienceBar:SetPoint('LEFT', oUF_AftermathhPlayer, -25, 0)
  34. ExperienceBar:SetStatusBarTexture(AftermathhUI.media.texture)
  35. ExperienceBar:SetSize(235, 18)
  36. ExperienceBar:SetStatusBarColor(0.6, 0, 0.6)
  37. ExperienceBar:SetBackdrop({
  38.     bgFile = AftermathhUI.media.blank,
  39.     insets = {top = -1, left = -1, bottom = -1, right = -1},
  40.     })
  41. ExperienceBar:SetBackdropColor(unpack(AftermathhUI.media.backdropcolor))
  42.  
  43. CreateBorderLight(ExperienceBar, AftermathhUI.media.bordersize, AftermathhUI.bordercolor, AftermathhUI.bordercolor, AftermathhUI.bordercolor, 3)
  44.  
  45. ExperienceBar:EnableMouse()
  46.    
  47. ExperienceBar:SetScript("OnEnter", function(self)
  48.     GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  49.     GameTooltip:AddLine("|cffffd200Experience|r")
  50.     GameTooltip:AddDoubleLine("Current EXP", Current, 1, 1, 1, 1, 1, 1)
  51.     GameTooltip:AddDoubleLine("Remaining EXP", Max - Current, 1, 1, 1, 1, 1, 1)
  52.        
  53.     if Rested == nil then
  54.         GameTooltip:AddDoubleLine("Rested EXP", "0", 1, 1, 1, 1, 1, 1)
  55.     else
  56.         GameTooltip:AddDoubleLine("Rested EXP", Rested, 1, 1, 1, 1, 1, 1)
  57.     end
  58.  
  59.     GameTooltip:Show()
  60. end)
  61.    
  62. ExperienceBar:SetScript("OnLeave", function()
  63.     if GameTooltip:IsShown() then
  64.     GameTooltip:Hide()
  65.     end
  66. end)
  67.    
  68. ExperienceBarRested:SetSize(230, 18)
  69. ExperienceBarRested:SetAlpha(0.5)
  70. ExperienceBarRested:SetParent(ExperienceBar)
  71. ExperienceBarRested:SetAllPoints(ExperienceBar)
  72. ExperienceBarRested:SetStatusBarTexture(AftermathhUI.media.texture)
  73. ExperienceBarRested:SetStatusBarColor(0, 144/255, 1)
  74.  
  75. ExperienceFont:SetFont(AftermathhUI.media.font, 12, AftermathhUI.media.fontflag)   
  76. if AftermathhUI.media.shadowoffset == true then
  77.     ExperienceFont:SetShadowOffset(1, -1)
  78.     ExperienceFont:SetShadowColor(0,0,0)
  79. end
  80.  
  81. Experience:RegisterEvent("PLAYER_XP_UPDATE")
  82. Experience:RegisterEvent("PLAYER_LEVEL_UP")
  83. Experience:RegisterEvent("UPDATE_EXHAUSTION")
  84. Experience:RegisterEvent("PLAYER_ENTERING_WORLD")
  85. Experience:RegisterEvent("PLAYER_UPDATE_RESTING")
  86.  
  87. Experience:SetScript("OnEvent", UpdateExp)
  Reply With Quote