View Single Post
04-14-24, 01:56 PM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Spell power increase message and animation

Hello,
I created this script for display a message whenever spell power get increased. I'd like to make the animation repeat only once. Are there better methods than the ones I'm using? What about spell power 'ping'?


Lua Code:
  1. local fs = UIParent:CreateFontString(nil, "OVERLAY", "GameTooltipText")
  2. fs:SetPoint("CENTER")
  3. fs:SetFont("Fonts\\FRIZQT__.TTF", 24, "OUTLINE")
  4. fs:SetText("Spell power increased!")
  5. fs:SetAlpha(0)
  6. fs.flasher = fs:CreateAnimationGroup()
  7.  
  8. fs.flasher:SetLooping("NONE")
  9.  
  10. fs.flasher:SetScript(
  11.     "OnUpdate",
  12.     function()
  13.         if fs:GetAlpha() == 0 and fs.flasher:IsPlaying() then
  14.             fs:Hide()
  15.         end
  16.     end
  17. )
  18.  
  19. local fade = fs.flasher:CreateAnimation("Alpha")
  20. fade:SetDuration(5)
  21. fade:SetChange(-1)
  22. fade:SetOrder(1)
  23.  
  24. local spellDmg = GetSpellBonusDamage(6)
  25.  
  26. local onupdate = CreateFrame("Frame")
  27.  
  28. local spellDmg = GetSpellBonusDamage(6)
  29.  
  30. onupdate:SetScript("OnUpdate", function(self,elapsed)
  31.     if GetSpellBonusDamage(6) > spellDmg then
  32.         fs:SetAlpha(1)
  33.         fs:Show()
  34.         fs.flasher:Play()
  35.     end
  36.     spellDmg = GetSpellBonusDamage(6)
  37. end)
  Reply With Quote