WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Cannot get spell id from tooltip generated by metashowtooltip (https://www.wowinterface.com/forums/showthread.php?t=59368)

fatrog 11-23-22 11:58 AM

Cannot get spell id from tooltip generated by metashowtooltip
 
Hello,

I'm facing a problem while trying to get spellid from tooltips. When I try to get it from a macro tooltip, it returns nil

Here is my code

Code:

_G["GameTooltip"]:HookScript("onShow",function(self)
   
    local spellName, spellID = self:GetSpell()
    print(spellID)
end)

The macro have a metashowtooltip (#showtooltip) instruction and the spell is well shown in the (what I thought was) the global tooltip.

Thanks for your help

EDIT: mounts return nil too. neither spells or items methods work

fatrog 11-23-22 02:30 PM

I got myself through it :)

here's how I did it

Code:

_G["GameTooltip"]:HookScript("onShow",function(this)

    local cooldownMS, gcdMS, spellName
    local spellName, spellID = this:GetSpell()
    local 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
end)



All times are GMT -6. The time now is 06:50 AM.

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