View Single Post
08-01-08, 08:44 PM   #7
LBXZero
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 61
Taffu is correct. With the original code in the first post, if the player logs in with out a pet or the mod loads too early, petName will be nil. It is because it only sets petName when the script is read the first time.

The best solution is to register for event UNIT_PET because it fires when something happens to your pet. It should always occur during loading if the pet is out when logging in.

Code:
function HEmote_OnLoad (self)
 this:RegisterEvent("PET_ATTACK_START");
 self:RegisterEvent("UNIT_PET");
...

function HEmote_OnEvent(self, event, ...)
if (event == "UNIT_PET") then
  petName = UnitName("pet");
 elseif (petName and HEon == "1") then
 ...
  Reply With Quote