Thread Tools Display Modes
11-09-18, 07:31 AM   #1
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
GetItemInfo() returning lots of nil values

I got a bug report for my addon suggesting that my call of

Code:
local _, _, _, _, itemMinLevel, _, itemSubType, _, _, _, _, itemTypeId = GetItemInfo(itemLink)
with
Code:
itemLink = "|cff0070dd|Hitem:157953::::::::120:255::25:2:1487:4785:::|h[Bilewing Helmet]|h|r"
is returning a lot of nil values (in particular for itemMinLevel):
Code:
_ = nil
_ = nil
_ = nil
_ = nil
itemMinLevel = nil
_ = nil
itemSubType = nil
_ = nil
_ = nil
_ = nil
_ = nil
itemTypeId = nil
(*temporary) = 120
(*temporary) = "player"
(*temporary) = 120
Or am I misreading the error message?
Unfortunately, I do not have this item "Bilewing Helmet", so I cannot try to reproduce this behaviour.

Could anybody have a look at this for me or give me another idea of how to approach this?

Here is again the bug report with the full error message:
https://github.com/LudiusMaximus/Bag...Level/issues/1

Thanks!
  Reply With Quote
11-09-18, 08:55 AM   #2
Rilgamon
Premium Member
 
Rilgamon's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Sep 2009
Posts: 822
GetItemInfo is not always providing correct information the moment you query it.
See Details: https://wow.gamepedia.com/API_GetItemInfo
Register
https://wow.gamepedia.com/GET_ITEM_INFO_RECEIVED
or ITEM_DATA_LOAD_RESULT when you query it through the new ITEM-API eg C_Item.GetItemNameByID
__________________
The cataclysm broke the world ... and the pandas could not fix it!

Last edited by Rilgamon : 11-09-18 at 08:58 AM.
  Reply With Quote
11-09-18, 09:12 AM   #3
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Thanks a lot for this hint!

Let me elaborate if I understand your suggestion of registering GET_ITEM_INFO_RECEIVED correctly:

Function1 calls GetItemInfo() and quits.

Then another Function2 is called whenever the GET_ITEM_INFO_RECEIVED event is triggered, getting as an argument only the itemId of the item for which the info was received.

But how does Function2 then get all the variables of Function1 that need to be altered depending on the received item info? I could only think of Function1 storing these values in a common table with itemId as the key?
  Reply With Quote
11-09-18, 09:23 AM   #4
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
Or am I not understanding the concept of GET_ITEM_INFO_RECEIVED right?

Is the server always queried after GetItemInfo(), meaning that every call of GetItemInfo() is followed by GET_ITEM_INFO_RECEIVED?
Or is there only a GET_ITEM_INFO_RECEIVED, if the item info has not yet been in the client's "cache"?
  Reply With Quote
11-09-18, 12:27 PM   #5
Banknorris
A Chromatic Dragonspawn
 
Banknorris's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 153
You query for the item and check if the returns are nil if they are then you register for GET_ITEM_INFO_RECEIVED check if arg1 is the item id and call GetItemInfo() again for that item id. This time the returns will be valid. But if the values from the first call were not nil then you should just use the returns because you won't get a GET_ITEM_INFO_RECEIVED with that item id in this case. The server only query once for an item and cache it. I am just not sure if some itens never get queried in the first place.
__________________
"In this world nothing can be said to be certain, except that fractional reserve banking is a Ponzi scheme and that you won't believe it." - Mandrill
  Reply With Quote
11-09-18, 02:50 PM   #6
LudiusMaximus
A Rage Talon Dragon Guard
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 320
All right, thanks. As my addon is a Bagnon plugin, I think Bagnon has already registered GET_ITEM_INFO_RECEIVED to trigger the necessary update. All I needed to do was to catch the case of GetItemInfo() returning nil, I hope... :-)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetItemInfo() returning lots of nil values

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