View Single Post
11-03-14, 09:39 AM   #1
devilArt
A Wyrmkin Dreamwalker
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 51
Need some help about UNIT_POWER

edit: so my question is how can i make low mana alert only plays when I'm on mage/warlock/priest/paladin, and disable low mana alert when I'm on dk/rouge/warrior/hunter?

--------------------------------------------------------------------

I use this code to play a alert sound when I'm low health or mana
but how can I disable low mana alert when I'm playing DK?


Lua Code:
  1. local lowHealth = .2
  2. local lowMana   = .3
  3.  
  4. local playedHp, playedMp
  5. local f = CreateFrame("Frame")
  6. f:SetScript("OnEvent", function(self, event, unit, pType)
  7.     if unit ~= "player" then return end
  8.     if event == "UNIT_HEALTH" or event == "UNIT_MAXHEALTH" then
  9.         if UnitHealth("player") / UnitHealthMax("player") < lowHealth then
  10.             if not playedHp then
  11.                 playedHp = true
  12.                 PlaySoundFile("Interface\\AddOns\\media\\LowHealth.ogg")
  13.             end
  14.         else
  15.             playedHp = false
  16.         end
  17.     elseif event == "UNIT_POWER" or event == "UNIT_MAXPOWER" and pType == "MANA" then
  18.         if UnitPower("player") / UnitPowerMax("player") < lowMana then
  19.             if not playedMp then
  20.                 playedMp = true
  21.                 PlaySoundFile("Interface\\AddOns\\media\\LowMana.ogg")
  22.             end
  23.         else
  24.             playedMp = false
  25.         end
  26.     end
  27. end)
  28.  
  29. f:RegisterEvent("UNIT_HEALTH")
  30. f:RegisterEvent("UNIT_POWER")
  31. f:RegisterEvent("UNIT_MAXHEALTH")
  32. f:RegisterEvent("UNIT_MAXPOWER")

Last edited by devilArt : 11-03-14 at 11:39 AM.
  Reply With Quote