RegisterULocalPlayerExecPreHook
注册一个回调,在调用 ULocalPlayer::Exec 前执行。
除字符串、布尔值和 FOutputDevice 外,参数必须通过 Param:Get() 读取,通过 Param:Set() 设置。
回调可以有两个返回值。
- 如果第一个返回值为空(或 nil),使用 Exec 的原返回值。
- 如果第一个返回值为 true 或 false,该值会覆盖 Exec 的原返回值。
- 第二个返回值控制是否执行原始 Exec。
- 如果第二个返回值为 nil 或 true,会执行原始 Exec。
- 如果第二个返回值为 false,不会执行原始 Exec。
参数
| # | 类型 | 说明 |
|---|---|---|
| 1 | function | 要注册的回调 |
回调参数
| # | 类型 | 说明 |
|---|---|---|
| 1 | ULocalPlayer | 本地玩家上下文 |
| 2 | UWorld | 世界 |
| 3 | string | 命令 |
| 4 | FOutputDevice | AR 输出设备 |
回调返回值
| # | 类型 | 说明 |
|---|---|---|
| 1 | bool | 是否覆盖 Exec 的原返回值 |
| 2 | bool | 是否执行原始 Exec |
示例
local function MyCallback(Context, InWorld, Command, Ar)
-- Do something with the parameters
-- Return true or false to override the original return value of Exec
-- Return false to prevent the original Exec from executing
return nil, true
end
RegisterULocalPlayerExecPreHook(MyCallback)
原文:docs/lua-api/global-functions/registerulocalplayerexecprehook.md · 固定提交 560411f18512 · 来源与 MIT 许可