hookfunction
Replaces a function with your own implementation and returns the original so you can still call it. The workhorse of most hooks.
Signature
hookfunction<A1..., R1..., A2..., R2...>(functionToHook: (A1...) -> R1..., hook: (A2...) -> R2...): (A1...) -> R1...Parameters
functionToHook(A1...) -> R1...The function to replace.
hook(A2...) -> R2...The replacement that runs in its place.
Returns
function
Note
Example
local old
old = hookfunction(print, function(...)
return old("[hooked]", ...)
end)