Trying to count the number of debuffs with x name with player as source from nameplates.
What am i doing wrong? very new at coding but trying to learn for entertainment and knowledge.
here is the variations i tried
variaton 1:
local DebuffCount = 0
local spellname = "Stellar Flare"
local playerName = UnitName("player")
for i = 1, 20 do " +
local unit = "nameplate" .. i
if UnitExists(unit) then
for j = 1, 40 do
if select(11, UnitDebuff(unit,i)) == spellname and select(8, UnitDebuff(unit, i)) == playerName then
DebuffCount = DebuffCount + 1
end
end
end
end
return DebuffCount
|
variation 2:
local DebuffCount = 0
local spellname = "Stellar Flare"
local playerName = UnitName("player")
for i = 1, 20 do
local unit = "nameplate" .. i
if UnitExists(unit) then
for j = 1, 40 do
local name, _, _, _, _, _, _, caster, _, _, spellId = UnitDebuff(unit, j)
if name == spellname and caster == playerName then
DebuffCount = DebuffCount + 1
end
end
end
end
return DebuffCount
|