Thread Tools Display Modes
09-02-16, 08:52 AM   #1
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
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
Code:
print:NumLines()
will just return nil beyond that first duplicated item.

any idea what's causing this?
  Reply With Quote
09-02-16, 11:09 AM   #2
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-02-16, 12:08 PM   #3
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
here's the full code including the tooltip scan:

https://github.com/obble/iipui/blob/...poweritems.lua

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.

Last edited by ObbleYeah : 09-02-16 at 12:13 PM.
  Reply With Quote
09-02-16, 03:09 PM   #4
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
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!
__________________
Grab your sword and fight the Horde!
  Reply With Quote
09-02-16, 03:37 PM   #5
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
What happens if you do :ClearLines() before each :Set*
  Reply With Quote
09-03-16, 02:45 AM   #6
ObbleYeah
A Cobalt Mageweaver
AddOn Author - Click to view addons
Join Date: Sep 2008
Posts: 210
appears to work. quick, easy fix — thanks!
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » duplicate conjured items breaking tooltip scanning

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