WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   GetItemInfo() returning lots of nil values (https://www.wowinterface.com/forums/showthread.php?t=56836)

LudiusMaximus 11-09-18 07:31 AM

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!

Rilgamon 11-09-18 08:55 AM

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

LudiusMaximus 11-09-18 09:12 AM

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?

LudiusMaximus 11-09-18 09:23 AM

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"?

Banknorris 11-09-18 12:27 PM

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.

LudiusMaximus 11-09-18 02:50 PM

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... :-)


All times are GMT -6. The time now is 08:59 PM.

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