View Single Post
11-29-14, 10:56 PM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Basic code to spam the UIErrorsFrame with "Follower Name @ 42% HP!" while your follow's health is under 50%.

Code:
local alertFor = {
    ["Follower Name A"] = true,
    ["Follower Name B"] = true,
}
local f = CreateFrame("Frame")
f:RegisterUnitEvent("UNIT_HEALTH", "focus")
f:SetScript("OnEvent", function(self, event, unit)
     local name = UnitName(unit)
     if not alertFor[name] then return end
     local hp, hpmax = UnitHealth(unit), UnitHealthMax(unit)
     local percent = hp / hpmax
     if percent < 0.5 then
          UIErrorsFrame:AddMessage(format("%s @ %d%% HP!", name, percent * 100)
     end
end)
If you need help turning the above code into an addon, copy and paste it into this page:
http://addon.bool.no/
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote