Convert ItemID's to Item Details
Hi all
I am building a small addon that converts an itemID into an extended itemDetails table. I have a function that loops through a list of itemID's and gets the full item details which I then insert as a table into another table. When I check the results in the saved variables file I get a list with only the hearthstone details, all the other entries display only the itemID. My convert function, (links to my full code are at the bottom of this post) Lua Code:
Lua Code:
Here is my toc Here is my saved variables results Any help solving this would be great. |
Haven't fully checked it, but keep in mind that data from GetItemInfo isn't always instantly available. Check the Details section at the WoWpedia page.
I don't know if you have any of those other items, but you're likely to always have a Heartstone, which might be why it's the only one that has data instantly available. |
Hi LanceDH
Thanks for your reply. You are correct that the hearthstone details are available as it already my bags, so thanks for pointing that out for me. I also found your link great as it hinted at some other avenues that may hold the answer I am looking for. Cheers |
When I did something similar you got to listen for GET_ITEM_INFO_RECEIVED
if ( event == "GET_ITEM_INFO_RECEIVED" ) then -- STL_LogTextLine( "STL - GET_ITEM_INFO_RECEIVED " ); local arg1, arg2, arg3, arg4, arg5, arg6 = ...; --STL_LogTextLine("[" .. tostring(arg1) .. "] [" .. tostring(arg2) .. "] [" .. tostring(arg3) .. "] [" .. tostring(arg4) .. "] [" .. tostring(arg5) .. "] [" .. tostring(arg6) .. "]" ); --RecordLoot(iItemID, ""); AsyncUpdateItems(arg1); end and then local function AsyncUpdateItems(itemID) local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, iconFileDataID, itemSellPrice, itemClassID, itemSubClassID, bindType, expacID, itemSetID, isCraftingReagent = GetItemInfo(itemString); end itemString is already known so you must be ready before the event comes in (have a map or something) or use the itemID but I do not know off the top of my head would have to dig more to fine it |
Hi doofus
Thanks for your reply. I can see the concept of your chunks but I am still confused. I have a list of itemID’s that I loop through, then I use GetItemInfo(currentItemID) which then triggers the ‘GET_ITEM_INFO_RECEIVED’ event. I can use the event to trigger my one shot function myOneShotFunction(currentItemID) to get all the item details as a table that I can then insert into another table. How do I pause my loop through function until the event triggers and my one shot function completes? I know that this is probably an easy concept for those that have a coding background but to say that I am a noob when it comes to coding is a massive understatement. Cheers |
I can't really think of any practical reason why caching this information is necessary. I would honestly loop through the list and run GetItemInfo() on load (ignoring the returns) to force the game to query the items, then run GetItemInfo() again on what specific item I need info on when I need it. Saves a lot of trouble in the long run with negligible if any resource impact.
If your list is really long, you may opt to build a queue. Lua Code:
PS: If GetItemInfoInstant() gets you all the info you need, I'd suggest using that instead as all the data that accesses is on the client, so it doesn't need to query the server. |
Hi SDPhantom
Thanks for your reply. The reason I need to perform these actions is that I already have addon that stores itemID’s only however I want to introduce filters without having to query the server each time I need to update a scroll frame, as this freezes the game each time I scroll. When I convert all the itemID’s to itemsDetails that should allow me to sort through itemDetails to select all those that are rarity 1. Your suggestion to query the server first did work, so I can query then I do the convert the list is compete. I had not seen a queue solution either, so thanks for sharing that :) Cheers |
All times are GMT -6. The time now is 12:43 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI