Originally Posted by Vrul
UnitGUID can return nil so you need to account for that:
Code:
local function UnitIsPet(unit)
local GUID = UnitGUID(unit)
return GUID and tonumber(GUID:sub(5, 5), 16) % 8 == 4
end
UnitGUID returns nil when the game first loads so probably best to wait for a PLAYER_ENTERING_WORLD event to use it. If that's not an option you could do something more generic:
Code:
local function UnitIsPet(unit)
return UnitPlayerControlled(unit) and not UnitIsPlayer(unit)
end
Your code:
Code:
if UnitCreatureType("beast") or UnitCreatureType("demon") or UnitCreatureType("elemental") then
self.name:SetTextColor(1, 1, 1)
else
self.name:SetTextColor(color.r, color.g, color.b)
end
doesn't work because UnitCreatureType takes unitIDs like 'target' and returns string like 'Beast' or 'Demon'. It wouldn't work the way you want anyway since it would return 'Beast' for a druid in bear or cat form.
|
Thank You for the info.
I have added:
Code:
local function UnitIsPet(unit)
return UnitPlayerControlled(unit) and not UnitIsPlayer(unit)
end
and bugsack is not giving me any errors and my all player pets have there names with a white color.
Thanks again
Coke