Originally Posted by Mahiro
you could try
Code:
local petName; if UnitExists("pet") then petName = UnitName("pet"); end
|
If it's called when you first login and your pet isn't called (dismiss/call while in-game) the local will have to be reup'd via an event or update call of some sort doing it this way.
Because pets go in and out as far as existence is concerned...you may want to try attaching the variable update to an event. Try UNIT_PET or PET_BAR_UPDATE (or both) for variable updates. Something like:
Code:
local petName
function MyAddOn:UNIT_PET()
if ( UnitExists("pet") ) then
petName = UnitName("pet")
else
petName = ""
end
end
There's a few different ways you could do it. This is just one. This requires seperate OnEvent handlers for each event, so might have to make some adjustments there.