Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-22-23, 05:59 AM   #1
phatzz
A Defias Bandit
Join Date: Feb 2023
Posts: 3
Why does my code give no error, but always return 0

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

Last edited by phatzz : 02-22-23 at 06:17 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Why does my code give no error, but always return 0


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off