script_function
在已加载的脚本字节码中,用 IDA 风格特征在目标程序里定位入口,将参数压入该脚本线程栈并执行一次脚本虚拟机调用。脚本内存 API 总览。
会切换 TLS 并调用脚本 VM,须在脚本线程中执行。从 gui_tick、on_present 触发请用 fiber.run(function() ... end),或写在 on_tick、script.create 回调里。
目标脚本未运行、特征匹配不到或参数类型/顺序与脚本期望不一致时,call 返回 false。特征串错误可能导致游戏异常,请谨慎使用。
script_function.call(opts)bool, value?
opts 为表字段:
| 字段 | 类型 | 说明 |
|---|---|---|
script | string | number | 必填。脚本名(按 joaat 规则)或已算好的脚本哈希。 |
pattern | string | 必填。IDA 风格字节码特征(空格分隔十六进制,? 通配)。 |
args | table? | 可选。从 1 起连续下标的参数表;支持 bool、整数(压 int32 或 int64)、非整数字(压 float)。最多 32 个。 |
result | string? | 可选。返回值槽类型:void(默认)、int、uint、int64、float、bool;未识别时第二返回值仍为 nil。 |
成功时返回 true 与(若指定了 result)解码后的值;失败时返回 false, nil。
local ok, _ = script_function.call({
script = "am_pi_menu",
pattern = "2D 03 14 00 00 72 72",
args = { true, 0, 208508824 },
})
if not ok then notify.warn("调用失败") endscript_function.find_pc(opts)number | nil
仅解析特征在目标脚本程序中的程序计数器偏移,不执行 VM。字段 script、pattern 与 call 相同。找不到时返回 nil。
| 字段 | 类型 | 说明 |
|---|---|---|
script | string | number | 必填。 |
pattern | string | 必填。 |