Try this (no idea if it works!)
Code:
function GetBuffIndex(thisBuff)
local counter = 1
local buffIndex = 0
while (UnitBuff("player", counter)) do
if (string.find(UnitBuff("player", counter), thisBuff)) then
buffIndex = counter;
end
counter = counter + 1
end
return buffIndex
end
In your code, buffIndex was only in scope inside the while loop, so once you dropped out it became undefined
OK... Done some playing around in luapad (great tool for this kind of thing)
With lightning shield, mana spring totem, tranquil air totem buffs on me I ran :
Code:
counter = 1
while (UnitBuff("player", counter)) do
ace:print(counter..":"..UnitBuff("player", counter))
counter = counter + 1
end
And it produced :
1:Interface\Icons\Spell_Nature_LightningShield
2:Interface\Icons\Spell_Nature_ManaRegenTotem
3:Interface\Icons\Spell_Nature_StoneSkinTotem
So... Whilst with a bit of tweaking your code may work, it seems the UnitBuff() call returns the Icon name, not the spell name.