WoWInterface (
-   Lua/XML Help (
-   -   duplicate conjured items breaking tooltip scanning (

ObbleYeah 09-02-16 08:52 AM

duplicate conjured items breaking tooltip scanning
hi! i'm currently fiddling with a tooltip scan to cache items in my inventory that give artifact power on use. the function checks the tooltip and then pulls the container id and rewarded amount listed in the tooltip into a function to create a button that can be clicked to use the item.

Lua Code:
  1. for i = 0, 4 do
  2.             for j = 1, GetContainerNumSlots(i) do
  3.                 local item = GetContainerItemLink(i, j)
  4.                 local id   = GetContainerItemID(i, j)
  5.                 if id then
  6.                     tooltip:SetHyperlink(item)
  7.                     local two = _G[tooltip:GetName()..'TextLeft2']
  8.                     if two and two:GetText() then
  9.                         if strmatch(two:GetText(), 'Artifact Power') then
  10.                             local four = _G[tooltip:GetName()..'TextLeft4']:GetText()
  11.                             local ap   = string.match(four, '%d+')
  12.                             if ap then show(id, ap) break end
  13.                         end
  14.                     end
  15.                 end
  16.             end
  17.         end

this works fine, UNTIL i create two separate stacks of conjured items and place them side-by-side in the container (ie. by pressing auto-sort). this will then break tooltip line returns for all items after the first instance of the duplicated item. adding

will just return nil beyond that first duplicated item.

any idea what's causing this?

Lombra 09-02-16 11:09 AM

I don't really understand what you're doing here, but since you break the inner loop at some point, it will only ever find a maximum of one item per bag.

ObbleYeah 09-02-16 12:08 PM

here's the full code including the tooltip scan:

and an example of how the tooltip for the item im scanning for is formatted in-game (minus the item level line that wowhead inserts):

the break on first return is intentional. its a single action button that displays the first found instance of an item with that matched string (an artifact power item) in the inventory. as i see it there's no point iterating after that, and once the item is used then the function runs again and picks up the next one or runs through with nothing found, and the button doesn't show.

this works fine in practice, unless there's two of the same item in sequence in the container (ContainerFrame1Button1 has conjured mana biscuit, ContainerFrame1Button2 has... conjured mana biscuit) wherein either the hyperlink or the id seems to fail or conflict somehow, meaning the tooltip isn't populated with information and returns nil.

Lombra 09-02-16 03:09 PM

Just tried quickly with ItemRefTooltip, and indeed, setting the same item a second time hides the tooltip, so that'll be your issue I suppose!

Dridzt 09-02-16 03:37 PM

What happens if you do :ClearLines() before each :Set*

ObbleYeah 09-03-16 02:45 AM

appears to work. quick, easy fix thanks!

All times are GMT -6. The time now is 06:19 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI