Skip to content

Instantly share code, notes, and snippets.

@tekkub
Created September 10, 2009 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tekkub/184299 to your computer and use it in GitHub Desktop.
Save tekkub/184299 to your computer and use it in GitHub Desktop.
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