Thread Tools Display Modes
05-16-13, 04:11 PM   #1
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
stuck with little lua

So i wanna do new feature for my addon, i wanna display Thunderforged (+) next to dropped item, for example if boss drop items [A B B+ A C], i have list in chat
1. Ax2
2. B
3. B+
4. C
Thing is, sometimes i fail to detect Thunderforge, and have no idea why.

Lua Code:
  1. if LootTooltipTextLeft2:GetText() ~= nil then
  2.                 if not (LootTooltipTextLeft2:GetText() == ITEM_HEROIC or LootTooltipTextLeft2:GetText() == ITEM_BIND_ON_PICKUP or LootTooltipTextLeft2:GetText():match(USE_COLON) or LootTooltipTextLeft2:GetText():match(ITEM_LEVEL)) then
  3.                     upgrade[i] = LootTooltipTextLeft2:GetText()
  4.                 end
  5.             end

Sometimes it work, sometimes dont.
If i do print after first "if", and there are tooltip line 2 for given item, it wont fire either
I was thinking i should track GET_ITEM_INFO_RECEIVED, but that cannot be case because when i click for same windows second time, its not working wither



My whole current lua file in attachment
(it is absolutly terrible piece of code, i would write it now with table of arrays and table.remove todetect duplicate drops, that would save me all those loops, problems with iteration i guess)

If someone would peek, i would appreciate
Attached Files
File Type: lua simplelootannouncer.lua (2.7 KB, 240 views)
  Reply With Quote
05-17-13, 11:56 AM   #2
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Have you thought about using ilvl to determine Thunderforged status?

Lua Code:
  1. local _, link, ilvl
  2. for index = 1, GetNumLootItems() do
  3.     link = GetLootSlotLink(index)
  4.     _, _, _, ilvl = GetItemInfo(link)
  5.     if (ilvl == 528) or (ilvl == 541) then
  6.         --this item is Thunderforged
  7.     else
  8.         --this item is not Thunderforged
  9.     end
  10. end
__________________
Knowledge = Power; Be OP


Last edited by Gethe : 05-17-13 at 06:58 PM. Reason: Reg TF is 528 not 428 /derp
  Reply With Quote
05-17-13, 01:15 PM   #3
Mazzop
A Cliff Giant
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 74
I will have too, just wondering why GetText() dont always work, because it work sometimes, if it was totally bad then i would not have partial results
  Reply With Quote
05-17-13, 01:46 PM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
If it's working sometimes then you're trying to access the font string before the tooltip has been populated.

The text is not available immediately after setting the item unless you already have it cached.

You need to request item information from the server and wait for a response before processing the data.
  Reply With Quote
05-17-13, 01:49 PM   #5
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Well mining the tooltip, to me, looks a bit messy overall, so I try to avoid it. That aside i've had trouble using more than one "or" conditional in a single statement like you have, so that's also something to look at.
__________________
Knowledge = Power; Be OP

  Reply With Quote
05-17-13, 05:36 PM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Regardless of how you get it, item information is not immediately available, even to api functions like GetItemInfo, until it's been cached.

Be careful how you use them.
  Reply With Quote
05-17-13, 06:12 PM   #7
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
Just to avoid confusion, the 428 in Gethe's post should be 528.
  Reply With Quote
05-17-13, 07:01 PM   #8
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
Originally Posted by Clamsoda View Post
Just to avoid confusion, the 428 in Gethe's post should be 528.
Yeah, not sure how that slipped through... /fixed
__________________
Knowledge = Power; Be OP

  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » stuck with little lua


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