WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Show battle pet level (https://www.wowinterface.com/forums/showthread.php?t=56932)

GreyFox777 12-30-18 05:58 PM

Show battle pet level
 
Hi there,

im trying to create an tag for battle pet level showing, but without any success...

Can some one show me right code for this?

my code for normal units seems like

Code:

tags[myaddon:levelclassification'] = function(unit)
                local l = UnitLevel(unit)

  return l


end


Kanegasi 12-30-18 09:22 PM

Third return of C_PetJournal.GetPetInfoByPetID().

Lua Code:
  1. local _, _, level = C_PetJournal.GetPetInfoByPetID( C_PetJournal.GetSummonedPetGUID() )

This only works for your current summoned pet. The API does not support getting info from other player's pets, you'll have to scrape their tooltip for their level.

GreyFox777 12-30-18 11:22 PM

And what about pet quality? Need to be same summoned?

Nightness 12-31-18 01:30 AM

Quote:

Originally Posted by GreyFox777 (Post 331204)
And what about pet quality? Need to be same summoned?

Google is your friend (Bing too!!), took me 1 minute to find this...

health, maxHealth, power, speed, rarity = C_PetJournal.GetPetStats("petID")

p3lim 12-31-18 02:15 AM

For reference, the default [level] tag:
https://github.com/oUF-wow/oUF/blob/....lua#L221-L232

Lua Code:
  1. ['level'] = [[function(u)
  2.     local l = UnitLevel(u)
  3.     if(UnitIsWildBattlePet(u) or UnitIsBattlePetCompanion(u)) then
  4.         l = UnitBattlePetLevel(u)
  5.     end
  6.     if(l > 0) then
  7.         return l
  8.     else
  9.         return '??'
  10.     end
  11. end]],

GreyFox777 12-31-18 10:45 AM

@p3lim

thank you very much! Exactly what i looked for.

Have searched whole google, and didn't found this :D


All times are GMT -6. The time now is 02:08 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI