As I said in the title...I'm going mad. You may know I've written SkillsPlusFu, and have been happy with it, but recently (or rather for the past couple months) it's been behaving strangely. The behaviour concerns the Alchemy skill cooldowns.
I've got the following setup:
-- declare the database on account level
Code:
SkillsPlusFu:RegisterDefaults("account", {
-- lists
cooldownSave = {}, -- cooldown info per character (middle part of list)
...
}
)
-- register the TRADE_SKILL_CLOSE event and intialise the toonSaveKey
Code:
function SkillsPlusFu:OnEnable()
...
-- cooldown management
self:RegisterEvent('TRADE_SKILL_CLOSE')
...
-- variables
toonSaveKey = GetCVar('realmName')..'|'..UnitName('player')
end
-- TRADE_SKILL_CLOSE event handler (stripped most Transmute spells)
-- loops spells and if it finds a transmute, write it and consider things done
Code:
function SkillsPlusFu:TRADE_SKILL_CLOSE()
local cooldownItem = nil
local cooldown = nil
local numSkills = GetNumTradeSkills()
local alchemyCooldown = false
for i=1, numSkills do
local itemName = GetTradeSkillInfo(i)
-- check alchemy cooldowns by spellID
if alchemyCooldown == false then
if( itemName == GetSpellInfo(11479) or -- Transmute: Iron to Gold
... [all other transmutes listed by spell ID]
itemName == GetSpellInfo(53784) -- Transmute: Eternal Water to Fire
) then
cooldownItem = L["COOLDOWN_TRANSMUTES"]
cooldown = GetTradeSkillCooldown(i)
if (cooldown == nil) then cooldown = 0 end -- safety catch; should cooldown be removed (or wrong spell ID used
-- self:Print('Found: '..itemName..format(cooldown))
-- write alchemy cooldown information to the database
self:WriteCooldownInfo(cooldownItem,cooldown)
alchemyCooldown = true
end
end
-- check for tailoring and jewelcrafting cooldowns each with a specific cooldown
if ( -- itemName == GetSpellInfo(18560) or -- Mooncloth (cooldown removed in 2.4.3)
itemName == GetSpellInfo(26751) or -- Primal Mooncloth
itemName == GetSpellInfo(31373) or -- Spellcloth
itemName == GetSpellInfo(36686) or -- Shadowcloth
itemName == GetSpellInfo(47280)) then -- Brilliant Glass
-- write the actual cooldown information to the database
self:WriteCooldownInfo(itemName,GetTradeSkillCooldown(i))
end
end
self:Update()
end
-- the actual write to DB function, note the debugger
Code:
function SkillsPlusFu:WriteCooldownInfo(itemName,cooldown)
-- general cooldown function
if (cooldown == nil) then cooldown = 0 end
if (self.db.account.cooldownSave[toonSaveKey] == nil) then
self.db.account.cooldownSave[toonSaveKey] = {}
end
if (self.db.account.cooldownSave[toonSaveKey][itemName] == nil) then
self.db.account.cooldownSave[toonSaveKey][itemName] = {}
end
self.db.account.cooldownSave[toonSaveKey][itemName].Cooldown = format(cooldown)
self.db.account.cooldownSave[toonSaveKey][itemName].LastCheck = time()
self.db.account.cooldownSave[toonSaveKey][itemName].IsReady = 0
if self.db.account.cooldownSave[toonSaveKey][itemName].Hide == nil then
self.db.account.cooldownSave[toonSaveKey][itemName].Hide = false
end
self:Print('Logged: '..toonSaveKey..' '..itemName..' '..format(self.db.account.cooldownSave[toonSaveKey][itemName].Cooldown))
end
So what happens that drives me crazy?
I have a transmuter and every time I do a transmute, the timer gets reset. I get the Printed debugger. I can see the timer is reset in the FuBar tooltip and from the menu (showing something like
Alchemy (0/1)).
Now the strange thing happens. When I logoff and swap toons. The cooldown says it's ready in the FuBar tooltip and from the menu (showing something like
Alchemy (1/1)).
Swaping again, I run a chance (doesn't always seem to happen which drives me even crazier) to see the previous character to have acquired a ready Transmute cooldown (even with Alchemy not part of their skills) This shows both in the FuBar tooltip and from the menu (showing something like
Alchemy (2/2)).
If I go back to the Alchemist and open and close the Tradeskill-window the timer gets reset again. With a proper debugger messages.
Shutting down after a clean start, will show the SavedVariables file to have saved the cooldown as ready (but I still see no messages of the counter being reset to zero).
The tailor stuff in the second bit of code seems to work fine and each piece of cloth-cooldown is properly saved (although my tailor just acquired a Transmute cooldown).
Frankly, I can't see what's going on and it's driving me round the bend. Help would be much appreciated.