Skip to content

Instantly share code, notes, and snippets.

@Shadowed
Created September 6, 2009 21:02
Show Gist options
  • Save Shadowed/181979 to your computer and use it in GitHub Desktop.
Save Shadowed/181979 to your computer and use it in GitHub Desktop.
local eventHealth = {}
local updateHealth = {}
local alreadyUpdated = {}
local units = {["player"] = true}
for i=1, 40 do
units["raid" .. i] = true
end
if( frame ) then frame:UnregisterAllEvents(); frame:SetScript("OnUpdate", nil); frame:SetScript("OnEvent", nil); frame:Hide() end
frame = CreateFrame("Frame")
frame:RegisterEvent("UNIT_HEALTH")
frame:SetScript("OnEvent", function(self, event, unit)
eventHealth[unit] = UnitHealth(unit)
alreadyUpdated[unit] = nil
end)
frame:SetScript("OnUpdate", function(self, elapsed)
for unit in pairs(units) do
local health = UnitHealth(unit)
if( eventHealth[unit] and updateHealth[unit] and updateHealth[unit] ~= eventHealth[unit] and not alreadyUpdated[unit] ) then
print("Health diff for", UnitName(unit), "event:", eventHealth[unit], "update:", health)
alreadyUpdated[unit] = true
end
updateHealth[unit] = health
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment