I can't seem to get over my problems loading in my DB and cycling through it, here is the relevant sections of my code:
local FACTIONITEMS_DEFAULT = {}
FactionItemsFu = FuBarPlugin:GetInstance("1.2"):new({
name = FactionItemsFuLocals.NAME,
description = FactionItemsFuLocals.DESCRIPTION,
version = "0.3.0",
releaseDate = "05-29-2006",
aceCompatible = 103,
author = "LordRhys",
email = "plugin@writer.com",
website = "" target="" data-ensure-absolute>http://plugin--writer.wowinterface.com/",
category = "others", -- Set this to the appropriate category.
db = AceDatabase:new("FactionItemsDB"),
defaults = FACTIONITEMS_DEFAULT,
cmd = AceChatCmd:new(FactionItemsFuLocals.COMMANDS, FactionItemsFuLocals.CMD_OPTIONS),
loc = FactionItemsFuLocals,
hasIcon = false,
showOnRight = false,
updateTime = 1.0,
})
function FactionItems:VarsLoaded() <-- This is called by Event Variables_Loaded
local testVars = self.db:Get()
if (testVars == nil) then
self:LoadVars()
end
end
function FactionItemsFu:LoadVars()
self.db:set({"Glowing Scorpid Blood"},"bank", 0)
self.db:set({"Glowing Scorpid Blood"},"inv",0)
self.db:set({"Glowing Scorpid Blood"},"mail",0)
self.db:set({"Evil Bat Eye"},"bank",0)
self.db:set({"Evil Bat Eye"},"inv",0)
self.db:set({"Evil Bat Eye"},"mail",0)
self.db:set({"Vibrant Plume"},"bank",0)
self.db:set({"Vibrant Plume"},"inv",0)
self.db:set({"Vibrant Plume"},"mail",0)
self.db:set({"Soft Bushy Tail"},"bank",0)
self.db:set({"Soft Bushy Tail"},"inv",0)
self.db:set({"Soft Bushy Tail"},"mail",0)
self.db:set({"Torn Bear Pelt"},"bank",0)
self.db:set({"Torn Bear Pelt"},"inv",0)
self.db:set({"Torn Bear Pelt"},"mail",0)
...etc...
end
function FactionItems:Inv_Change()
for k,var in self.db:Get() do
local ItemCount = GetBagItems(k)
self.PutInvCount(k,ItemCount)
end
end
I cannot tell if it is loading the data but I get errors in the function Inv_Change() giving me a nil in FactionItemsDB at the for loop. Can anyoone give me some advice?
you don't need to worry about the vars loaded event with ace. you'r Initialize method is called after vars loaded, always. Just do whatever you need on Init or Enable and you'll be fine.
I was about to reply that I still can't get it working, getting nil value error FactionItems returning nil. While copying code I noticed that all my functions were missing the Fu part in their declaration... using FactionItems: instead of FactionItemsFu:, hopefully this will solve all my problems.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
local FACTIONITEMS_DEFAULT = {}
FactionItemsFu = FuBarPlugin:GetInstance("1.2"):new({
name = FactionItemsFuLocals.NAME,
description = FactionItemsFuLocals.DESCRIPTION,
version = "0.3.0",
releaseDate = "05-29-2006",
aceCompatible = 103,
author = "LordRhys",
email = "plugin@writer.com",
website = "" target="" data-ensure-absolute>http://plugin--writer.wowinterface.com/",
category = "others", -- Set this to the appropriate category.
db = AceDatabase:new("FactionItemsDB"),
defaults = FACTIONITEMS_DEFAULT,
cmd = AceChatCmd:new(FactionItemsFuLocals.COMMANDS, FactionItemsFuLocals.CMD_OPTIONS),
loc = FactionItemsFuLocals,
hasIcon = false,
showOnRight = false,
updateTime = 1.0,
})
function FactionItems:VarsLoaded() <-- This is called by Event Variables_Loaded
local testVars = self.db:Get()
if (testVars == nil) then
self:LoadVars()
end
end
function FactionItemsFu:LoadVars()
self.db:set({"Glowing Scorpid Blood"},"bank", 0)
self.db:set({"Glowing Scorpid Blood"},"inv",0)
self.db:set({"Glowing Scorpid Blood"},"mail",0)
self.db:set({"Evil Bat Eye"},"bank",0)
self.db:set({"Evil Bat Eye"},"inv",0)
self.db:set({"Evil Bat Eye"},"mail",0)
self.db:set({"Vibrant Plume"},"bank",0)
self.db:set({"Vibrant Plume"},"inv",0)
self.db:set({"Vibrant Plume"},"mail",0)
self.db:set({"Soft Bushy Tail"},"bank",0)
self.db:set({"Soft Bushy Tail"},"inv",0)
self.db:set({"Soft Bushy Tail"},"mail",0)
self.db:set({"Torn Bear Pelt"},"bank",0)
self.db:set({"Torn Bear Pelt"},"inv",0)
self.db:set({"Torn Bear Pelt"},"mail",0)
...etc...
end
function FactionItems:Inv_Change()
for k,var in self.db:Get() do
local ItemCount = GetBagItems(k)
self.PutInvCount(k,ItemCount)
end
end
I cannot tell if it is loading the data but I get errors in the function Inv_Change() giving me a nil in FactionItemsDB at the for loop. Can anyoone give me some advice?
Thanks,
LordRhys