Addon Creation Question

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 :stuck_out_tongue:

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)

Are you getting an error message?
(You must have error messages enabled: /console scriptErrors 1)

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?

The error message is (hopefully) on page 2/2 of the window in your screen shot.
Can you check this and post it, please?

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.

Thank you sir. I did an edit now :stuck_out_tongue:

group and player seem undefined to me.
Also, I don’t know what the function bit.band is supposed to do.
What are you trying to do with that?

Technically when in a group/raid and someone dies, a sound plays and a text with the name of the player who died appears.

OK, I see what you want to achieve. But what are the variables player and group and the function bit.band() supposed to do for that?

from what I can see that

local group = COMBATLOG_OBJECT_AFFILIATION_PARTY

is missing

Okay thank you, i will test it now.

I tested and it doesn’t work. Maybe written in the wrong place or what could the code look like. Can you please add 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. :cold_sweat: But you can remove it freely. Removed local band = bit.band because the code is actually shorter without it.

1 Like

Thank you, sir. Gonna test it today.
Edit: I tested, the message appears but the sound doesn’t play when the said person dies.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.