Created
September 10, 2009 04:28
-
-
Save tekkub/184299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local f = CreateFrame("Frame") | |
f:SetScript("OnEvent", function(self, event, ...) if self[event] then return self[event](self, event, ...) end end) | |
local hp_events = { | |
"UNIT_HEALTH", -- HP changed | |
"UNIT_MAXHEALTH", -- Max HP changed | |
} | |
local function hp_func(self, event, unit, ...) | |
if unit ~= "target" then return end | |
local min, max = UnitHealth(unit), UnitHealthMax(unit) | |
--[[ do your HP shit ]] | |
end | |
for _,event in pairs(hp_events) do | |
f[event] = hp_func | |
f:RegisterEvent(event) | |
end | |
local mp_events = { | |
"UNIT_MANA", "UNIT_RAGE", "UNIT_FOCUS", "UNIT_ENERGY", "UNIT_RUNIC_POWER", -- MP changed | |
"UNIT_MAXMANA", "UNIT_MAXRAGE", "UNIT_MAXFOCUS", "UNIT_MAXENERGY", "UNIT_DISPLAYPOWER", "UNIT_MAXRUNIC_POWER", -- Max MP changed | |
} | |
local function mp_func(self, event, unit, ...) | |
if unit ~= "target" then return end | |
local min, max = UnitMana(unit), UnitManaMax(unit) | |
--[[ do your MP shit ]] | |
end | |
for _,event in pairs(mp_events) do | |
f[event] = mp_func | |
f:RegisterEvent(event) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment