GetItemInfo hanging? - WoWInterface
Thread Tools Display Modes
07-06-19, 02:45 AM   #1
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
GetItemInfo hanging?

I'm looping through a SavedVariable storing loot history. Printing line by line with a link to the item within the line. However, when create a SavedVariable with a 100 item history, when I load the game it will do one of them and then error out saying that the variable is nil, expecting value. But it's only once. So basically every time I reload the UI, it'll add one more item successfully to the list until I have the entire list printed out. Then it will no longer error out. Almost as if GetItemInfo is not able to keep up with the loop.

Lua Code:
  1. for i=1, #DKP_Log do
  2.     local itemToLink = select(2,GetItemInfo(DKP_Log[i]["loot"])) -- log holds Item ID
  4.     .... write variable to fontstring ....
  5. end

error received: Interface\AddOns\DKP\ConfigMenuTabs.lua:546: attempt to concatenate local 'itemToLink' (a nil value)

Just seems really strange that once all items have been loaded, it's fine until the game is restarted. Is there a way to delay the loop on each iteration?
  Reply With Quote
07-06-19, 03:09 AM   #2
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 131
If the item hasn't been encountered since the game client was last started, this function will initially return nil, but will asynchronously query the server to obtain the missing data, triggering GET_ITEM_INFO_RECEIVED when the information is available.
Since you store the item already, you should store the actual link because it carries more data than the itemId (like forging, sockets and bonus effects)

To get some information about an item immediately, you can use GetItemInfoInstant
Lua Code:
  1. itemID, itemType, itemSubType, itemEquipLoc, icon, itemClassID, itemSubClassID = GetItemInfoInstant(itemID or "itemString" or "itemName" or "itemLink")

Though it is not documented, this function apparently returns info available directly in client files. Because of that it returns less data, but have several advantages over GetItemInfo: it always return data, when GetItemInfo can return nil for valid, but not loaded items and it never initiates requests to server, that could be subject to throttling or forced disconnection.
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker
  Reply With Quote
07-06-19, 03:31 AM   #3
A Fallenroot Satyr
Join Date: May 2007
Posts: 24
My goal was to minimize the footprint of the SavedVariable file. But if storing the string is the best method I'll go ahead and do that. Thank you
  Reply With Quote
07-06-19, 11:41 AM   #4
A Molten Giant
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 531
Word of advice for add-on files, either SavedVariables or the add-on itself: Do not worry about how much space or memory you use. There is no difference between storing 100 item IDs and storing 100 item strings. In fact, it's a waste of CPU having to look up those item IDs. Always consider CPU, space/memory is never an issue. Better to save data than look it up.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » GetItemInfo hanging?

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