Thread Tools Display Modes
Prev Previous Post   Next Post Next
11-23-22, 05:15 PM   #1
fatrog
A Fallenroot Satyr
Join Date: Nov 2022
Posts: 21
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
 

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