From 5c981390970cc6fe1e3111ce55e40b1d71b6f9fc Mon Sep 17 00:00:00 2001 From: atomaka Date: Sun, 21 Aug 2011 14:10:05 -0400 Subject: [PATCH] Reset instance lockout if necessary. --- ChoreTracker.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ChoreTracker.lua b/ChoreTracker.lua index 307aef8..10ea611 100644 --- a/ChoreTracker.lua +++ b/ChoreTracker.lua @@ -26,21 +26,31 @@ function core:OnEnable() self.db.profile.lockouts[name] = {} end - self:RegisterEvent('UPDATE_INSTANCE_INFO','StoreChores') + self:RegisterEvent('UPDATE_INSTANCE_INFO','UpdateChores') end -function core:StoreChores() - local _,_,_,earnedThisWeek = GetCurrencyInfo(396) - local name = UnitName('player') +function core:UpdateChores() local level = UnitLevel('player') if(level == 85) then + local _,_,_,earnedThisWeek = GetCurrencyInfo(396) + local name = UnitName('player') + + --reset data if necessary + for k,v in pairs(self.db.profile.lockouts) do + for x,y in pairs(self.db.profile.lockouts[k]) do + if y.resetTime > time() then + self.db.profile.lockouts[k][x] = nil + end + end + end + --store Valor Points self.db.profile.valorPoints[name] = earnedThisWeek --store Saved Instances local savedInstances = GetNumSavedInstances() - for i = 0, savedInstances do + for i = 1, savedInstances do local instanceName,_,instanceReset,_,_,_,_,_,_,_,_,defeatedBosses = GetSavedInstanceInfo(i) if trackedInstances[instanceName] == true then