Hi guys, I’ve created my own addon that whenever someone from the party dies, an ogg file plays and a text in the middle appears. The thing is I created the addon in Legion and it worked. Now I want to make it work in Shadowlands and in classic servers. Can I get some help please, it doesn’t work. All I need is a quick look at the script please
local player = COMBATLOG_OBJECT_TYPE_PLAYER
local band = bit.band
local color = {r = 1, g = 1, b = 0}
local f = CreateFrame("Frame")
function f:OnEvent(event, timestamp, subevent, _, _, sourceName, _, _, destGUID, destName, destFlags)
if subevent == "UNIT_DIED" then
if band(destFlags, group) > 0 and band(destFlags, player) > 0 then
RaidNotice_AddMessage(RaidWarningFrame, format("%s has fallen", destName:match("(.-)%-") or destName), color)
PlaySoundFile("Interface/AddOns/AllyHasFallen/SentinelAllyHeroDies1.ogg")
end
end
end
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
f:SetScript("OnEvent", f.OnEvent)
I’m a legit noob. Its my second addon in years. [ Lua error]( imgur. com/a/M3s9mkd) I wrote here on this website with a bit of help.
addon. bool. no
The thing is I didn’t use any software now (I forgot what I used in the past), I just took it from an archive I had it since Legion. I thought it was pretty much the same engine. Can you please help me? Any way to test it in-game via a command?
Umm, it’s empty :)) both pages. I disabled all addons and only activated the one created by me. For some reasons, it doesn’t display anything sadly. Only empty space.
Make sure to wrap your code in a code block `x3 above and below when posting on the forums or the forums turns your quotes into smart quotes etc and breaks it.
Alright, restructered it a little and it seems to work now:
local player = COMBATLOG_OBJECT_TYPE_PLAYER
local group = bit.bor(COMBATLOG_OBJECT_AFFILIATION_RAID, COMBATLOG_OBJECT_AFFILIATION_PARTY,COMBATLOG_OBJECT_AFFILIATION_MINE)
local color = {r = 1, g = 1, b = 0}
local f = CreateFrame("Frame")
function f:COMBAT_LOG_EVENT_UNFILTERED()
local timeStamp, subevent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags = CombatLogGetCurrentEventInfo()
if subevent == "UNIT_DIED" then
if bit.band(destFlags, group) > 0 then
if bit.band(destFlags, player) > 0 then
RaidNotice_AddMessage(RaidWarningFrame, format("%s has fallen", destName:match("(.-)%-") or destName), color)
print(format("%s has fallen", destName:match("(.-)%-") or destName))
PlaySoundFile("Interface/AddOns/AllyHasFallen/SentinelAllyHeroDies1.ogg")
end
end
end
end
f:SetScript("OnEvent", function(self, event, ...)
self[event](self, ...)
end)
f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
Added COMBATLOG_OBJECT_AFFILIATION_MINE into group variable for the sake of testing. To see my own demise. But you can remove it freely. Removed local band = bit.band because the code is actually shorter without it.