I've been trying to write a simple addon script to place a raid marker on the targets of a spell (e.g. Wild Growth). However - I'm having a small problem. I will correctly be marked when I receive Wild Growth, but other raid members will not.
I've checked the values of the variables before calling UnitBuff (they seem sensible), but it doesn't return true (even when they definitely have the Wild Growth buff active).
The code is below (I've never written any LUA before so please excuse the standard...) Can anyone help please?
Code:
local frame = CreateFrame("Frame", "PastaAddonFrame");
frame:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED");
--Set counter for raid marker
local raidMarkIndex = 1
frame:SetScript("OnEvent", function(self, event, unit, spellName, ...)
if ((event == "UNIT_SPELLCAST_SUCCEEDED") and (spellName == "Wild Growth")) then
--Check raid members
for i=1,25 do
local raidUnit = "raid"..i
if UnitExists(raidUnit) then
--If member has buff, mark
if UnitBuff(raidUnit, spellName) then
--Set raid marker
SetRaidTarget(raidUnit, raidMarkIndex)
--Increment raid mark index
raidMarkIndex = raidMarkIndex + 1
--Reset raid mark index after 6
if raidMarkIndex > 6 then
raidMarkIndex = 1
end
end
end
end
end
end)