# HG changeset patch # User contrebasse # Date 1302217260 -7200 # Node ID 5336b3a19d4ff18e629e377d178fd7fe8befc2bd # Parent 250d01156e219b75ff33c7802316b6e1302f9066 Throttle the scanning to avoid freezing wow diff -r 250d01156e21 -r 5336b3a19d4f ReagentMaker.lua --- a/ReagentMaker.lua Wed Apr 06 00:32:00 2011 +0200 +++ b/ReagentMaker.lua Fri Apr 08 01:01:00 2011 +0200 @@ -27,8 +27,14 @@ --------------------------------------------------- A.EventsFrame = CreateFrame("Frame") -A.EventsFrame:SetScript("OnEvent", function(self, event, ...) - if event == "TRADE_SKILL_UPDATE" then +local SCAN_DELAY = 0.2 +local t_throttle = SCAN_DELAY +local function throttleScan(self, t_elapsed) + t_throttle = t_throttle - t_elapsed + if t_throttle<0 then + self:SetScript("OnUpdate", nil) + print("go") + -- Close the external window if the tradeskill changed if A.currentTradeSkill ~= GetTradeSkillLine() then A.MenuFrame:Hide() @@ -41,12 +47,30 @@ -- Scan availabe recipes A:ScanSimpleRecipes() + end +end +A.EventsFrame:SetScript("OnEvent", function(self, event) + print(self,event) + if event == "TRADE_SKILL_UPDATE" then + t_throttle = SCAN_DELAY + self:SetScript("OnUpdate", throttleScan) + + --[[ + -- Close the external window if the tradeskill changed + if A.currentTradeSkill ~= GetTradeSkillLine() then + A.MenuFrame:Hide() + end - elseif event == "TRADE_SKILL_SHOW" then if IsTradeSkillGuild() or IsTradeSkillLinked() then A.MenuFrame:Hide() return end + + -- Scan availabe recipes + A:ScanSimpleRecipes() + --]] + + elseif event == "TRADE_SKILL_SHOW" then A:Initialize() A.EventsFrame:UnregisterEvent("TRADE_SKILL_SHOW") end -- if