I'm sure this is just me being blind, but I'm getting the following error:
[2009/11/22 13:18:01-2331-x1]: Observer-0.1\Observer.lua:168: attempt to index field '?' (a nil value)
Observer-0.1\Observer.lua:181: in function `?'
CallbackHandler-1.0-5:146: in function <...non\libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:146>
<string>:"safecall Dispatcher[3]":4: in function <[string "safecall Dispatcher[3]"]:4>
<in C code>: ?
<string>:"safecall Dispatcher[3]":13: in function `?'
CallbackHandler-1.0-5:91: in function `Fire'
LibSharedMedia-3.0-90058:176: in function `Register'
SharedMedia-3.0.1-177\SharedMedia.lua:48: in main chunk
---
Yet, the odd thing is that this does not seem to effect my addon function at all. Everything works fine. Thoughts?
Apparently, you aren't allocating a texture for every entry in barFrames. If you're doing this intentionally, then you need to modify your code thusly:
function Observer:UpdateBarTextures()
local texturePath = LSM3:Fetch("statusbar", db.bar.texture)
for i = 0, #barFrames do
if barFrames[i].texture then
barFrames[i].texture:SetTexture(texturePath)
end
end
end
That's odd... Observer:AddBar(offset, text, color) should be generating a texture for each bar created.
Could it be that the for loop is executing when there aren't any bars at all? I was under the impression that for i=0, #barFrames should not loop at all if #barFrames is 0.
Also, your change doesn't seem to work. Same error.
If there are no entries, then the for loop will do nothing. I don't see anywhere other than its definition where Observer:AddBar() is used, so it's possible that the code which calls :AddBar() is doing so without filling all of the entries. In that case, it would be the barFrames[whatever] which is nil, not just its texture. In that case, you would need to change the if-check in the loop to this:
That would do it if #barFrames was non-zero. Your issue is probably the fact that you're setting i to 0 in your loop - in Lua, this is bad. Change it to 1.
In Omen, I used bars[0] specially for the title bar that users can toggle on/off (the bar with the column headings that says Name, TPS, Threat, etc). The threat bars start from [1] onwards.
Yet, the odd thing is that this does not seem to effect my addon function at all. Everything works fine. Thoughts?
Pasty is at: http://www.pastey.net/129310
Yes, I know the code isn't optimized :P
Could it be that the for loop is executing when there aren't any bars at all? I was under the impression that for i=0, #barFrames should not loop at all if #barFrames is 0.
Also, your change doesn't seem to work. Same error.
Also, the error is only generated a single time, at load, and before AddBar is even called.
edit:
Now that I think about it, could it be possible that the event that calls that function is being fired prior to barFrames being created?
edit:
That seems to have resolved it.
... Stupid fencepost errors...
Glad to hear it.