Thread Tools Display Modes
09-27-23, 07:52 AM   #1
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Can't read GameTooltip right text

This script should print the information reported in the GameTooltip created in this way. Specifically, it should print

—› Rank 5
—› 30 yd range

Lua Code:
  1. local f = CreateFrame("GameTooltip", "MyGameTooltip", UIParent, "GameTooltipTemplate")
  2. f:SetOwner(UIParent, "ANCHOR_NONE")
  3. f:SetSpellByID(27217) -- Drain Soul
  4. local n = 1
  5. while _G["MyGameTooltipTextRight"..n]:GetText() do
  6.    local text = _G["MyGameTooltipTextRight"..n]:GetText()
  7.    print(text)
  8.    n = n + 1
  9. end
  Reply With Quote
09-27-23, 09:30 AM   #2
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Wrong FontString (for Wrath)
Lua Code:
  1. while _G["MyGameTooltipTextLeft"..n]:GetText() do
  2.     print(n, "L:", _G["MyGameTooltipTextLeft"..n]:GetText())
  3.     n = n + 1
  4. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote
09-27-23, 09:44 AM   #3
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
It prints everything except the rank and range information
  Reply With Quote
09-27-23, 09:55 AM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Range is in MyGameTooltipTextRight2 (there is no MyGameTooltipTextRight1:GetText() so a loop for that would fail at the first test)

There is no rank

Show the tooltip at ANCHOR_CURSOR to see what it says.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 09-27-23 at 09:58 AM.
  Reply With Quote
09-27-23, 12:45 PM   #5
Benalish
A Flamescale Wyrmkin
 
Benalish's Avatar
Join Date: Dec 2012
Posts: 123
Solved, thank you!

Lua Code:
  1. local f = CreateFrame("GameTooltip", "MyGameTooltip", UIParent, "GameTooltipTemplate")
  2. f:SetOwner(UIParent, "ANCHOR_NONE")
  3. f:SetSpellByID(27217) -- Drain Soul
  4. local n = 2 --start from 2
  5. while _G["MyGameTooltipTextRight"..n]:GetText() do
  6.    local text = _G["MyGameTooltipTextRight"..n]:GetText()
  7.    print(text)
  8.    n = n + 1
  9. end
  Reply With Quote
09-27-23, 01:28 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,879
Depending on what you want to do but adjusting the start number seems to defeat the purpose of the loop

either just:
Lua Code:
  1. local text = MyGameTooltipTextRight2:GetText()
  2. if text then
  3.     print(text)
  4. end

or, if there might be something you want in position 1 or position x, check all TextRights:
Lua Code:
  1. local n = 1 --start from 1
  2. while _G["MyGameTooltipTextRight"..n] do
  3.    local text = _G["MyGameTooltipTextRight"..n]:GetText()
  4.    if text then
  5.        print(n, text)
  6.    end
  7.    n = n + 1
  8. end
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can't read GameTooltip right text


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