Problem reading Item tooltips for Recipes
I'm trying to read the tooltip data for a large number of items, but the basic code I'm using is having an issue; the tooltip is often incomplete. I write up a minimal test case and paste it into WoWLua using Design: Nightmare Tear as the item. No matter how many times I run it, the part of the recipe that is supposed to be after the item info is never there (mats, required skill).
Is there an error in my code or am I just not understanding how this should work? Lua Code:
|
I modify the code with my lib, if I use thread to call the myOnTooltipSetItem and make it wait until next OnUpdate, I get the require material and level texts.
So those text aren't generated together, we need a little delay to get all the result. Lua Code:
You may use the C_Timer.After to do the trick. |
I worry about using timer-based things like this because it doesn't feel reliable. If the server takes a little bit longer to respond with the recipe details, I'll still end up with a partial tooltip. I wish there were a reliable event to say that the tooltip is fully loaded like there is with Item Info.
|
I ran several test cases, if you access the item for the first time(start the game from the client), the require material and skill are query from the server, so wait a phase may not be enough, if you have accessed the item before, wait one phase will get those datas.
So, I re-modify the code like Lua Code:
This time I run the TestTT as thread, and use the GetItemInfo to check if we have already cached the item's info, if not, we need wait the GET_ITEM_INFO_RECEIVED system event and check its first argument. The API Wait I used is suspend the curoutine until the system event is fired or the delay of 1 sec is meet(since I can't make sure whether the item existed). Then I check if the received item id is the target item, and continue the job. ------------- I add the widget event handler in TestTT and remove it in the myOnTooltipSetItem, it seems the widget event would be fired several times since I delayed the hide of the gametooltip. |
Login + 3 UI-Reloads will show the complete text. So your code is correct but the information is not yet available. So you should really use GET_ITEM_INFO_RECEIVED like kurapica.igas suggests.
|
It all seems to be working well now, so thanks for all the feedback.
If anyone would get any use of it, you can grab a JSON dump of all items in WoW here: https://github.com/MuffinManKen/WoWData |
All times are GMT -6. The time now is 11:49 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI