View Single Post
03-23-13, 07:23 PM   #12
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Mazzop View Post
I crate that tooltip frame with GameTooltipTemplate, so strings there are as before any addons touch them?
Correct; addons that modify the GameTooltip frame don't affect other frames that also inherited from the GameTooltipTemplate or have the GameTooltip frame type. (Blizzard's naming choices here are a little silly... it's like creating a Button type frames and naming it "Button" even though there are also hundreds of other Button type frames in the UI.)

If you did want to try item level matching, you can capture it like so:

Code:
-- Construct your pattern once at the top of the file:
local ITEM_LEVEL_PATTERN = "^" .. gsub(ITEM_LEVEL, "%%d", "(%d+)") .. "$"

-- Then use it:
for i = 2, GameTooltip:GetNumLines() do
    local text = _G["GameTooltipTextLeft"..i]:GetText()
    if text then -- it can be nil, which is fine for == checks but will break string.match
        local iLevel = strmatch(text, ITEM_LEVEL_PATTERN)
        if iLevel then
             -- do something here
             break -- stop looking
        end
    end
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote