Thread Tools Display Modes
05-24-13, 11:50 PM   #1
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
get item level first result incorrect

I'm using an edited code to retrieve a targets current equipped item level and it always returns the wrong value the first time, but the correct value all times after that.

here what I have so far:

Lua Code:
  1. local u,t,c,l="target"
  2.     t,c=0,0
  3.     for i=1,17 do l=GetInventoryItemLink(u,i)
  4.         if l and i~=4 then
  5.             _,_,_,l=GetItemInfo(l)
  6.             c=c+1
  7.             t=t+l
  8.         end
  9.     end
  10. print(u .. "'s Item Level is: " t/c)

I Can't see the problem maybe someone else can =)
  Reply With Quote
05-25-13, 02:22 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
The information is available the second time because by inspecting the char for checking the values by hand invokes the following (I guess you check it by using the inspect window ):

http://www.wowpedia.org/API_NotifyInspect

Use this and wait for the relevant event to fire before you use your script.

Edit: While it "should" be no problem to use the _ not as a local it is good practice to make it local to make sure you dont mess in the global space.
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 05-25-13 at 02:24 AM.
  Reply With Quote
05-25-13, 02:11 PM   #3
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
I did what you said but it didn't work, I did manage to fix it though, but now I ran into another problem, using GetItemInfo to get item level does not include upgraded levels so a 522 upgraded to 530 only shows as 522

how do I get the upgraded levels aswell?
  Reply With Quote
05-25-13, 02:40 PM   #4
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Originally Posted by Spawnova View Post
I did what you said but it didn't work, I did manage to fix it though, but now I ran into another problem, using GetItemInfo to get item level does not include upgraded levels so a 522 upgraded to 530 only shows as 522

how do I get the upgraded levels aswell?
Unless i've overlooked something, the only functions that return upgrade info only do so when you are at the upgrade vendor with an item selected. If you need this info elsewhere you will need to mine the tooltip for it.
__________________
Knowledge = Power; Be OP

  Reply With Quote
05-25-13, 04:41 PM   #5
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
You can also check the upgrade level by parsing the itemString in an itemLink:

http://www.wowpedia.org/ItemString
  Reply With Quote
05-25-13, 05:20 PM   #6
Spawnova
A Warpwood Thunder Caller
 
Spawnova's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2012
Posts: 96
Everything works now =D I used phanx's code from another similar topic http://www.wowinterface.com/forums/s...ad.php?t=45388

Thanks everyone
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » get item level first result incorrect


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