hookfunction
Redirects a function's entry point to a custom hook.
function hookfunction(targettargetfunctionThe function whose execution is to be redirected.: function, hookhookfunctionThe replacement function that will be called instead.: function): functionfunctionA trampoline to the original implementation of the target function.Usage
Intercept print
local originalPrint = hookfunction(print, function(...)
-- Do something before
return originalPrint("[Intercepted]", ...)
end)
print("Hello") -- Output: "[Intercepted] Hello"