Go to http://addon.bool.no and paste the following code into the big box. You can put whatever you want in the "AddOn folder name". Then click "Create my AddOn" and extract the zip into Interface/AddOns.
Code:
local healthpercent=0.3 -- must be between 0 and 1
local healthcooldown=30 -- in seconds
local manapercent=0.3 -- must be between 0 and 1
local manacooldown=30 -- in seconds
local AutoEmote=CreateFrame('frame','AutoEmote')
AutoEmote:RegisterEvent('UNIT_HEALTH')
AutoEmote:RegisterEvent('UNIT_POWER')
local t={health=0,mana=0}
AutoEmote:SetScript('OnEvent',function(self,event,unit,power)
if unit=='player' then
local eventtime=time()
if event=='UNIT_HEALTH' then
local health=UnitHealth(unit)
local healthmax=UnitHealthMax(unit)
if health/healthmax<healthpercent and eventtime-t.health>healthcooldown then
DoEmote('HEALME')
t.health=eventtime
end
end
if event=='UNIT_POWER' and power=='MANA' then
local mana=UnitPower(unit)
local manamax=UnitPowerMax(unit)
if mana/manamax<manapercent and eventtime-t.mana>manacooldown then
DoEmote('OOM')
t.mana=eventtime
end
end
end
end)
This will automatically perform /healme and /oom when you go below 30% health or 30% mana. Each emote will only occur once every 30 seconds. If you want to change these values, change the four numbers at the top of the code as desired.