Hello,
I have made this to train myself
Lua Code:
local gcdMS, gcdMSControl, cooldownMS, spellName, spellName, spellID, itemName, ItemLink, gcdText
_G["GameTooltip"]:HookScript("onShow",function(this)
gcdMS, cooldownMS, spellName, spellName, spellID, itemName, ItemLink = nil
spellName, spellID = this:GetSpell()
itemName, ItemLink = this:GetItem()
if spellID ~= nil then
cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
print("ID:"..gcdMS)
elseif itemName ~= nil then
spellName, spellID = GetItemSpell(ItemLink)
cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
print("spell from item link:"..gcdMS)
else
spellName = _G[this:GetName().."TextLeft"..1]:GetText()
_,_,_,_,_,_,spellID = GetSpellInfo(spellName)
cooldownMS, gcdMS = GetSpellBaseCooldown(spellID)
print("spell with no ID:"..gcdMS)
end
gcdMS = round(gcdMS / 1000,2)
gcdText = ""
gcdText = "GCD "..gcdMS.."sec"
-- I add the text to the current tooltip
this:AddLine(gcdText,1,1,1)
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:
_G["GameTooltip"]:HookScript("onUpdate",function(this)
gcdMS = round(gcdMS / 1000,2)
gcdText = ""
gcdText = "GCD "..gcdMS.."sec"
this:AddLine(gcdText,1,1,1)
end)
Thank you