I defer to your expertise on this one. I'm now in chapter 12, and after thouroughly racking my brain and inspecting everything I've come to a puzzling situation. I thought the problem was my code, so I downloaded the example from chapter12.zip file. And I applied the corrections from the errata where you fixed the issue with quality.
This is the problem, the line in the bag scanning on the quality filter if statement
shown = shown and BagBuddy.filters[quality]:GetChecked()
it seems perfectly logical, but it throws an error inside wow
Date: 2010-11-26 18:11:13
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\BagBuddy\BagBuddy.lua line 69:
attempt to index field '?' (a nil value)
Debug:
[C]: ?
BagBuddy\BagBuddy.lua:69: BagBuddy_Update()
BagBuddy\BagBuddy.lua:192:
BagBuddy\BagBuddy.lua:183
AddOns:
Swatter, v5.9.4960 (WhackyWallaby)
ACP, v3.3.9
BagBuddy, v
Prat30, v3.4.13
Prat30HighCPUUsageModules, v
Prat30Libraries, v
WowLua, vv40000-1.0.0
BlizRuntimeLib_enUS v4.0.3.40000
(ck=cf)
Now. I've thrown a print statement before the shown statement to see what the issue is, and I don't get it. When I add `print(BagBuddy.filters[quality])` one line before shown I get all the tables for the buttons
[18:04:23] table: 0x3fb5e418
etc etc.
So the global table `BagBuddy.filters[quality]` is properly working, but when you pass it the method `GetChecked()` inside the function `BagBuddy_Update()` the statement fails. Using the `GetChecked()` method in the function `BagBuddy_Filter_OnClick()` works without a problem. :S I'm at a loss.
I've worked around the problem like this:
function BagBuddy_Filter_OnClick(self, button)
BagBuddy.qualityFilter = false
BagBuddy.qualityset = {}
for idx = 0, 5 do
local button = BagBuddy.filters[idx]
if button:GetChecked() then
BagBuddy.qualityFilter = true
BagBuddy.qualityset[idx] = true
end
end
BagBuddy.page = 1
BagBuddy_Update()
end
inside BagBuddy_Update():
if BagBuddy.qualityFilter then
shown = shown and BagBuddy.qualityset[quality]
end
By using a table and setting its items to true when checked inside the OnClick function. This workaround functions just fine, but the error puzzles me, and I'd like to know if you have any idea why it happens, its just odd that a method can be called fine in one function and not in another.
↧