Quantcast
AddLine new line disappear - WoWInterface
Thread Tools Display Modes
11-23-22, 05:15 PM   #1
fatrog
A Deviate Faerie Dragon
Join Date: Nov 2022
Posts: 17
AddLine new line disappear

Hello,

I have made this to train myself

Lua Code:
  1. local gcdMS, gcdMSControl, cooldownMS, spellName, spellName, spellID, itemName, ItemLink, gcdText
  2.  
  3. _G["GameTooltip"]:HookScript("onShow",function(this)
  4.  
  5.     gcdMS, cooldownMS, spellName, spellName, spellID, itemName, ItemLink = nil
  6.     spellName, spellID = this:GetSpell()
  7.     itemName, ItemLink = this:GetItem()
  8.  
  9.     if spellID ~= nil then
  10.  
  11.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  12.        print("ID:"..gcdMS)
  13.  
  14.     elseif itemName ~= nil then
  15.  
  16.        spellName, spellID = GetItemSpell(ItemLink)
  17.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  18.        print("spell from item link:"..gcdMS)
  19.  
  20.     else
  21.  
  22.        spellName = _G[this:GetName().."TextLeft"..1]:GetText()
  23.        _,_,_,_,_,_,spellID = GetSpellInfo(spellName)
  24.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  25.        print("spell with no ID:"..gcdMS)
  26.  
  27.     end
  28.  
  29.     gcdMS = round(gcdMS / 1000,2)
  30.     gcdText = ""
  31.     gcdText = "GCD "..gcdMS.."sec"
  32.     -- I add the text to the current tooltip
  33.     this:AddLine(gcdText,1,1,1)
  34. end)

So I got this `AddLine` method. And when I'm in the game and I mouse over a spell, it shows the text but only for less than a second.

I tried to make it so it's in the `onUpdate` method, but it does the same

Lua Code:
  1. _G["GameTooltip"]:HookScript("onUpdate",function(this)
  2.     gcdMS = round(gcdMS / 1000,2)
  3.     gcdText = ""
  4.     gcdText = "GCD "..gcdMS.."sec"
  5.     this:AddLine(gcdText,1,1,1)
  6. end)

Thank you
  Reply With Quote
11-24-22, 10:30 AM   #2
fatrog
A Deviate Faerie Dragon
Join Date: Nov 2022
Posts: 17
I have check others post about tooltip, but I can't find people discussing about that new line disappearing.

Any idea?
  Reply With Quote
11-24-22, 11:20 AM   #3
Vampyr78
A Murloc Raider
AddOn Author - Click to view addons
Join Date: May 2016
Posts: 8
This is how you attach a function to OnShow for GameTooltip now:

Code:
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, function)
This works for items, for spells you would need to duplicate it and change it to Enum.TooltipDataType.Spell.
  Reply With Quote
11-24-22, 01:56 PM   #4
fatrog
A Deviate Faerie Dragon
Join Date: Nov 2022
Posts: 17
Hey, thank you,
I should have known that I had to check patch changes >,< my bad..

Lua Code:
  1. local function GetDisplayGCDInfos(tt)
  2.     gcdMS, cooldownMS, spellName, spellName, spellID, itemName, ItemLink = nil
  3.     spellName, spellID = tt:GetSpell()
  4.     itemName, ItemLink = tt:GetItem()
  5.     if spellID ~= nil then
  6.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  7.        print("ID:"..gcdMS)
  8.     elseif itemName ~= nil then
  9.        spellName, spellID = GetItemSpell(ItemLink)
  10.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  11.        print("spell from item link:"..gcdMS)
  12.     else
  13.        -- MACRO WAS HERE
  14.        spellName = _G[tt:GetName().."TextLeft"..1]:GetText()
  15.        _,_,_,_,_,_,spellID = GetSpellInfo(spellName)
  16.        cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
  17.        print("spell with no ID:"..gcdMS)
  18.     end
  19.     gcdMS = round(gcdMS / 1000,2)
  20.     gcdText = ""
  21.     gcdText = "GCD "..gcdMS.."sec"
  22.     tt:AddLine(gcdText,1,1,1)
  23. end
  24.  
  25. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, GetDisplayGCDInfos)
  26. TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, GetDisplayGCDInfos)

Only thing, how do I check "other" types? I mean, since onshow was global, it worked on macros with showtooltip in it (I marked the line in my code above). I can't find where there's a list of types in the patch changes?
  Reply With Quote
11-24-22, 02:07 PM   #5
Vampyr78
A Murloc Raider
AddOn Author - Click to view addons
Join Date: May 2016
Posts: 8
https://github.com/tomrus88/Blizzard...umentation.lua

They are defined in this file.
  Reply With Quote
11-24-22, 04:41 PM   #6
fatrog
A Deviate Faerie Dragon
Join Date: Nov 2022
Posts: 17
Ok now I know where to search. Than you very much
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » AddLine new line disappear

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