文档加载中…
hookfunction
用新实现替换函数,同时保留对原函数的访问。
hookfunction(target: function, hook: function) -> function
target
function
hook
hookfunction 用 hook 替换 target。返回值是原始函数,调用它可执行未修改的行为。
在挂钩内部可使用 checkcaller() 区分 Volt 调用与游戏调用。
checkcaller()
local oldPrint = hookfunction(print, function(...) return oldPrint("[hooked]", ...) end) print("hello") -- 输出: [hooked] hello