View Single Post
06/04/14, 10:51 AM   #15
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Sasky View Post
Lua Code:
  1. local d_old = d
  2. d = function(...) end
  3. zo_callLater(function() d = d_old end, 2000)
It is not a good idea to restore function from backup, because you never know if any other addon hooks the same function after your addon is loaded.
Method used by thelegendaryof's BugEater is better.
Lua Code:
  1. local ignore = true
  2. ZO_PreHook("d", function() return ignore end)
  3.  
  4. EVENT_MANAGER:RegisterForEvent("Debug_Hook", EVENT_PLAYER_ACTIVATED,
  5.    function(event)
  6.       zo_callLater(function() ignore = false end, 250)
  7.       EVENT_MANAGER:UnregisterForEvent("Debug_Hook", event)
  8.    end)

EDIT:
I have to say that instead of hooking d(), it is better to use code provided by Fathis Ules. It works even if addon uses different method of displaying of chat "spam":
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("Clear_Chat", EVENT_PLAYER_ACTIVATED,
  2.    function(event)
  3.       zo_callLater(
  4.          function()      
  5.             for i = 1, #ZO_ChatWindow.container.windows do
  6.                if _G["ZO_ChatWindowTemplate"..i.."Buffer"] then _G["ZO_ChatWindowTemplate"..i.."Buffer"]:Clear() end
  7.              end
  8.          end, 250)
  9.       EVENT_MANAGER:UnregisterForEvent("Clear_Chat", event)
  10.     end)

Last edited by Garkin : 06/04/14 at 11:06 AM.
  Reply With Quote