WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   General Authoring Discussion (https://www.wowinterface.com/forums/forumdisplay.php?f=20)
-   -   Getting Tooltip Text (https://www.wowinterface.com/forums/showthread.php?t=59029)

ranjeet 01-28-22 05:23 PM

Getting Tooltip Text
 
I found a macro that will enumerate through whatever tooltip is showing but cannot get it to work when trying to run it straight from a LUA file.

The macro is:
/run for i=1,GameTooltip:NumLines()do local mytext=_G["GameTooltipTextLeft"..i] local text=mytext:GetText()print(text)end

It works perfectly when hovering over something in-game and running the macro via key binding. But in order to get it to work in the main LUA file for this addon, it needs to run when a tooltip is actually there and ready to read. I am able to execute it via:

GameTooltip:HookScript("OnTooltipSetDefaultAnchor", somefunction)

This was the only GameTooltip handler that would fire for tooltips that are not associated with an item or unit. I need it to fire when highlighting over a chest, which cannot be done with any of the other GameTooltip handlers.

Does anyone have any idea on how I can get this macro code to work? I tried putting it in somefunction without the '/run' but nothing happens. I would greatly appreciate the help.

Fizzlemizz 01-29-22 10:20 AM

This might be better until someone who knows more about it chips in:

Lua Code:
  1. GameTooltip:HookScript("OnShow", function(self)
  2.     print("|cff00ff00------")
  3.     for i=1, self:NumLines() do
  4.         print(_G["GameTooltipTextLeft"..i]:GetText())
  5.     end
  6. end)

ranjeet 01-31-22 11:03 AM

Thank you so much, this worked exactly how I wanted it to!


All times are GMT -6. The time now is 05:02 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI