Getting item details on hover
Hi all
I am looking for some help in regards to getting an itemID when I click an item in the adventure guide, my bags and my bank. I have worked out how to get the itemID of items in my bags and bank but it requires that I have to pick up the item first. Lua Code:
Is there a way to get an itemID on a down press or under the cursor rather than having to pick up the item first? and/or is there a call such as GetItemDetailsUnderCursor()? Also, I have had little luck finding a good tutorial on how to add keybindings to the binding UI so any help with pointing me to such an example/tutorial would be great. Cheers |
You can cycle through any container, whether bags on your person, in the bank, the guildbank slots or even what you are wearing ( I think ).
This link should point you in the right direction .. browse around and look for sample code to try in your addon. https://wow.gamepedia.com/World_of_Warcraft_API#Bags This is specific to what you are asking.. https://wow.gamepedia.com/API_GetContainerItemID https://wow.gamepedia.com/BagID |
Maybe something like this is what you're looking for?
It gets the itemLink from the item that is currently displayed on the tooltip and gets the itemID from the link. Lua Code:
To add bindings to the default UI you can use bindings.xml: https://wowwiki.fandom.com/wiki/Usin...for_your_addon |
Hi all
Sorry for the late reply, RL got a bit hectic. @Xrystal - Thanks for the links. With the GetContainerItemID it requires the BagID and the BagSlot, I cannot see any function to get the itemID orBagID and BagSlot by hovering. I did not know I could iterate through the dungeon guide however I would still hit the same issue as I need to get the itemID on hover. @sezz Your chunk would seem to be the answer that I am looking for however I have not been able to get it to work in game. Based on the advice your both provided I have read up and mucked around to finally come up with the following; Lua Code:
I test all code chunks in game using the Rehack addon. Any further help would be great. |
Quote:
Maybe if you explain what you want to use the link for. |
Hi all
My use case is I need to add the itemID of the item under the mouse to a table using a keybind. If the item is already listed a fail message must print, otherwise add the itemID to the table. Chunk of pseudo code; Lua Code:
Idealy I would use the binding F5-BUTTON1 to operate on up/release to fire the addItemToTable function one time only. |
Hi actually
I have made some progress on this brick wall. Now my toc looks like this; Toc Lua Code:
AAA.lua Lua Lua Code:
Also adding the itemID to a table does not work; my prints show the slash command and add item functions are being fired yet no item is saved to the table. I have probably made a noob mistake but I have not been able to nut this out. Any further help would be great. |
Delay your Setup after ADDON_LOADED or PLAYER_ENTERING_WORLD might help.
|
SavedVariables are global, TableOfItems is not really a unique enough name for a global. Same goes for frame names, "myTest" is not really a unique enough name for a global. You might be binding to some other "myTest" button.
Lua Code:
Lua Code:
|
Hi all
@Rilgamon, I didn't even think of that, I've been so focused on getting and using the hover to get the itemID that even the simplest of things passed over my head; thanks for reminding me :) @Fizzlemizz, I have tried your code however I still have the exact same issues. I have to /reload after entering world for the first time to get the button clicks to work, and, the list is still empty when I /qwe, I have also got the SavedVariables lua open so I can see if the itemIDs are saved on /reload just to ensure my /qwe was not working properly. I repaced my orriginal addItemToTable function with your chunk and I also renamed my table, button and vars, (i went a bit overboard with the names). Here is my current code; Lua Code:
I still have the issue that I have to /realod before the keybinds work. How do I ensure that the keybinds are available when I first log in? |
Lua Code:
|
Hi Fizzlemizz
Thanks for your code, it is much more legible and easier to follow than mine. However, it still has the same issue, I have to /reload after logging in to get the keybinds to work. After much gnashing of teeth, a few print statements and a hell of a lot of experimentation I ended up solving the problem by creating the button itself in a function and then having another frame to run the new function on the player entering the world. My full solution; Lua Code:
There is probaly a more efficent way of achieveing the same result but for now I am happy just to have it working. The next thing on my list is to have the keybindings show in the bindings menu so users can swap the bindings to a key of their choice. If I fail at that I will probably be back. Thank you all for the help :) |
I had no problem with the binding loging in from start-up, logout/login etc. Might I suggest you may have an addon binding the key(s) on a login event after your addons does and that event might not fire on /reload.
Just a thought. F5 default is target Party Member 4. |
Hi Fizzlemizz
No, I hadn't thought of that, it would make sense, however when you tested it at your end did you choose the same F5 key? I have not been able to find an alternate F5 keybind in the bind UI. Also a quick sideways, how do I bind the { or [ or \ keys in lua, in-game I can bind them in the binding UI but in lua I have no success? |
Those are special characters in Lua. You need to escape them when using them in a string, or use a literal string (square brackets instead of quotes).
Lua Code:
or Lua Code:
|
Hi all
@Seerah thanks for the escape code help, I had tried it earlier however I had "\\-CTRL" which did not work as the escape also took in the -CTRL so it never worked, now that I have "CTRL-\\" it works properly. I had never seen a literal string before, I will look into it more to understand what the difference is between a string and a literal string. Once I have got this working I will post it here so other novices like myself can find it. Thanks to you all for your help. |
Hi all
As promised I am posting my working code here for other novices like myself. Toc Lua Code:
Lua Code:
I will now start working out how to add these keybindings to the in-game keybinding UI. Thanks to you all for your help, it is most appreciated. |
All times are GMT -6. The time now is 06:55 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI