Issue with UnitBuff
Right so, this is a tiny addon i've had for a while to auto answer ready checks depnding on the situation.
Everything works exept the flask part, flask is always nil and i don't understand what i did wrong. Code:
local _, caelUI = ... |
GetSpellInfo returns multiple stuff, i guess you need the name of the spell.
name = GetSpellInfo(spellId or spellName or spellLink) http://www.wowwiki.com/API_GetSpellInfo Also i'm not sure GetSpellName is a valid API atm, and it's only for spellbook items so its useless for you. I think you need to use GetSpellInfo for food too. |
Quote:
|
Instead of worrying about the spell names, since you already have the spell IDs for the ones in which you have interest, why don't you just use UnitAura in a loop like:
flasks = {} -- fill this with each one local i = 1 local foundFLask = nil while (true) do local name,_,_,_,_,_,_,_,_,_,spellId = UnitAura("player", i) if name then spellId = tonumber(spellId) if tContains(flasks, spellId) then foundFlask = spellId end -- or use name if you want i = i + 1 else break end end |
You have a scoping problem.
Code:
for k, v in pairs(flasks) do Also also, since you are using an indexed table, you should use for i = 1, #flasks do local k = flasks[ i ] instead of for k, v in pairs(flasks) to avoid the slow call to pairs. |
Quote:
Code:
if flasks[spellId] then ... |
Not sure i understand what you meant with the function GetSpellName but here's what i did, if that's correct.
Code:
local _, caelUI = ... Code:
Error occured in: Global |
Lua Code:
|
Ok Zork, but isn't that a bit overkill, my food part was fine hehe :)
Any idea what's wrong in my version though ? |
No I don't think that it is overkill. If you need to add other food buffs in feature you can easily add them. Maybe you called UnitBuff with a nil string or if you have a name you still need the rank as described in the usage.
Quote:
|
Well yeah, that's exactly what i've been trying to fix
Code:
for i = 1, #flasks do prints out "nil" |
What does
Lua Code:
|
Quote:
Code:
1 |
That is hilarious.
Those are the return values of: http://wowprogramming.com/docs/api/GetSpellInfo Basically...name, rank, icon, etc... So your GetSpellName function does what you told it to do. It returns all values of GetSpellInfo and adds them to the table. >_< Change it to: Lua Code:
|
Seems to be working now, i need to test some more, because i'm in a raid right now.
But anyway, what's going on ? While it should only return the name it returns all the values, is that it ? |
No one has responded for awhile so I'll swoop in and steal the glory.
Lua.org - Multiple Results Quote:
Code:
local name, realm = UnitName('target') -- Two values returned from a single function call. |
Quote:
http://wowprogramming.com/docs/api/GetSpellName |
Quote:
|
You can grab the first return by enclosing your function call in parentheses.
(GetSpellInfo(spellID)) will discard everything but the first return. |
Gravedigger
Yey for grave digging an old issue because it came back...
Code:
local GetSpellName = function(id) 1. If i use the whispers of insanity, it works perfectly. 2. if i only leave one flask in the table, it works perfectly. 3. if i leave it like it is, flask returns nil. |
All times are GMT -6. The time now is 02:55 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI