Thread Tools Display Modes
12-30-18, 05:58 PM   #1
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
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
  Reply With Quote
12-30-18, 09:22 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
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.
  Reply With Quote
12-30-18, 11:22 PM   #3
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
And what about pet quality? Need to be same summoned?
  Reply With Quote
12-31-18, 01:30 AM   #4
Nightness
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Feb 2009
Posts: 32
Originally Posted by GreyFox777 View Post
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")
  Reply With Quote
12-31-18, 02:15 AM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
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]],
  Reply With Quote
12-31-18, 10:45 AM   #6
GreyFox777
A Cliff Giant
Join Date: Jan 2017
Posts: 75
@p3lim

thank you very much! Exactly what i looked for.

Have searched whole google, and didn't found this
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Show battle pet level

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off