WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   AddLine new line disappear (https://www.wowinterface.com/forums/showthread.php?t=59370)

fatrog 11-23-22 05:15 PM

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

fatrog 11-24-22 10:30 AM

I have check others post about tooltip, but I can't find people discussing about that new line disappearing.

Any idea?

Vampyr78 11-24-22 11:20 AM

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.

fatrog 11-24-22 01:56 PM

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?

Vampyr78 11-24-22 02:07 PM

https://github.com/tomrus88/Blizzard...umentation.lua

They are defined in this file.

fatrog 11-24-22 04:41 PM

Ok now I know where to search. Than you very much :)


All times are GMT -6. The time now is 05:10 AM.

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