View Single Post
02-22-23, 07:07 AM   #3
phatzz
A Defias Bandit
Join Date: Feb 2023
Posts: 3
Originally Posted by Vampyr78 View Post
No error means that code is correct according to the syntax and grammar rules of the language, that's it. I'm not sure what is wrong in your code but there is something wrong and probably it never gets to the line where you increase the counter.

I suggest you just debug it. Just put print() function with the variable you wanna check what value it has, does it ever has the value you actually expect. It is also an easy to way to check if your code ever enters inside the if statement. Just put a print inside it it. My first guess is that you are taking wrong values from UnitDebuff result because you used an outdated reference and the order of those values sometimes changes with expansions. So try running print(UnitDebuf(unit, i)) and see if the values you want to compare are the the positions you expect them.
I found the correct values to be 1 (name) and 7 (unitcaster) by dumping, but i still am unable to get any return other than zero even with lots of nameplate uits existing and having the debuff name. Im not sure the code is properly checking all debuffs on target instead of just the first debuff? other debuiffs might exist.
I think i might have soemthing wrong in the (select(1 and select(7 part?
Here is my current code:

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(1, UnitDebuff(unit, j)) == spellname and select(7, UnitDebuff(unit, j)) == playerName then
DebuffCount = DebuffCount + 1
end
end
end
end
return DebuffCount
  Reply With Quote