Could not get spell name in WOW addon

539 Views Asked by At

Trying to get name of a spell as it seems like

local spellName = select(1, CombatLogGetCurrentEventInfo())

returns something like numbers instead plain text like 158989565.009

I was trying to get spell name by function GetSpellInfo(i) but no luck Here is code sample that doesn't work:

local frame = CreateFrame("FRAME");
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");

frame:SetScript("OnEvent", function(self, event)
    local type = select(1, CombatLogGetCurrentEventInfo())

    if (type == "SPELL_DAMAGE") then

        local spellId = select(1, CombatLogGetCurrentEventInfo())
        local name = GetSpellInfo(spellId)

        SendChatMessage(name, "SAY", "COMMON", GetUnitName("PLAYERTARGET"));
    end
end)
1

There are 1 best solutions below

0
On

Late answer but see https://wow.gamepedia.com/COMBAT_LOG_EVENT

local playerGUID = UnitGUID("player")
local MSG_SPELL_DAMAGE = "Damaged %s with %s"

local frame = CreateFrame("Frame");
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
frame:SetScript("OnEvent", function(self, event)
    local timestamp, subevent, _, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, spellId, spellName, spellSchool = CombatLogGetCurrentEventInfo()

    if subevent == "SPELL_DAMAGE" and sourceGUID == playerGUID then
        print(MSG_SPELL_DAMAGE:format(destName, spellName))
    end
end)

Example message