Navigation menu

WoW:API hooksecurefunc: Difference between revisions

Jump to navigation Jump to search
→‎Example: Use the 3.0 print.
(→‎Example: Use the 3.0 print.)
Line 11: Line 11:


==Example==
==Example==
local echoHook = function (...)
  hooksecurefunc("CastSpellByName", print); -- Hooks the global CastSpellByName
  local msg = "";
  hooksecurefunc(GameTooltip, "SetUnitBuff", print); -- Hooks GameTooltip.SetUnitBuff
  for k,v in pairs({...}) do msg = msg .. k .. "=[" .. tostring(v) .."] "; end;
  DEFAULT_CHAT_FRAME:AddMessage("[Echo] " .. msg);
end;
  hooksecurefunc("CastSpellByName", echoHook); -- Hooks the global CastSpellByName
  hooksecurefunc(GameTooltip, "SetUnitBuff", echoHook); -- Hooks GameTooltip.SetUnitBuff
===Result===
===Result===
Hooks CastSpellByName and GameTooltip.SetUnitBuff without compromising their secure status. When those functions are called, prints their argument list into the default chat frame.
Hooks CastSpellByName and GameTooltip.SetUnitBuff without compromising their secure status. When those functions are called, prints their argument list into the default chat frame.