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: Quote:
Quote:
|
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. |
Quote:
I think i might have soemthing wrong in the (select(1 and select(7 part? Here is my current code: Quote:
|
Return 7 from UnitDebuff would be unitID eg. "player", not the name.
Instead of calling the select and UnitDebuff functions twice each iteration you could use: Code:
local spellName, _, _, _, _, _, unitID = UnitDebuff(unit, j) |
Quote:
I was able to get it working before i read your latest reply, using this code - but i see your solution is more elegant. I will now just remove the prints and incorporate this into my own little learning addon. thanks again! You were both helpful in identifying the faults in my code. The first error was inded wrong index from google to the current WoW API. The 2nd was the use of UnitName("player") that will return the actual name instead of "player". Code:
local DebuffCount = 0 |
Code:
local debuffName, _, _, _, _, _, _, _, _, _, _ = UnitDebuff(unit, j) Code:
local debuffName, _, _, _, _, _, unit = UnitDebuff(unit, j) Without the if/break you're going through 40 debuff checks for each unit that exists, even it the unit has none or less than 40 (which will be most if not all of them). |
All times are GMT -6. The time now is 05:42 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI