文档加载中…
checkcaller
返回当前函数是否由 Volt 调用。
checkcaller() -> boolean
boolean
true
false
checkcaller 返回一个布尔值,表示当前函数是否由 Volt 自身线程调用。这有助于区分你的调用与游戏发起的调用。
当你挂钩游戏函数时,你的代码和游戏都会触发该函数。可在挂钩内使用 checkcaller 来决定是执行自定义逻辑,还是透传给原始函数。
local old old = hookfunction(game.HttpGet, function(self, url, ...) if checkcaller() then -- 来自我们的脚本,允许通过 return old(self, url, ...) end -- 来自游戏的调用,可以拦截或修改 print("游戏尝试请求:", url) return old(self, url, ...) end) -- 我们主动调用,会通过 checkcaller() local result = game:HttpGet("https://example.com")