⌨️ 客户端
客户端存在的静态类。
🗿Static Class
This is a Static Class. Access it's methods directly with
.. It's not possible to spawn new instances.💂Authority
This static class can be accessed only on 🟧 Client side.
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
🗿 静态函数
| Returns | Name | Description | |
|---|---|---|---|
CopyToClipboard | 复制文本到剪贴板 | ||
Disconnect | 断开与服务器的连接 | ||
| table of Base Actor | GetActorsInRadius | 返回指定半径内的 Actor | |
| table of string | GetAllValuesKeys | 获取所有值键的列表 | |
| string | GetConnectedServerIP | 获取当前连接的服务器 IP:Port | |
| Base Entity or nil | GetEntityByID | 返回指定 ID 的实体 | |
| float | GetFrameTime | 获取当前的帧时间 | |
| string | GetLanguage | 获取客户端当前的语言 | |
| Player | GetLocalPlayer | 获取本地玩家 | |
| integer | GetLogLevel | 返回当前的日志级别 | |
| string | GetMap | 返回当前地图 | |
| float | GetNearClipPlane | 获取近裁剪面的值 | |
| table of table | GetPackages | 返回当前运行的包列表 | |
| integer | GetTime | 获取毫秒级 Unix 时间戳 | |
| any | GetValue | 获取指定键的值 | |
| boolean | IsPackageLoaded | 返回指定的包当前是否已加载 | |
OpenEscapeMenu | 打开 Esc 菜单 | ||
SetDebugEnabled | 启用/禁用调试设置以及允许使用客户端控制台 | ||
SetEscapeMenuText | 设置 Esc 菜单的文本 | ||
SetHighlightColor | 更改指定索引处高亮 Actor 的高亮颜色 | ||
SetNearClipPlane | 设置近裁剪面 | ||
SetOutlineColor | 更改指定索引处描边 Actor 的描边颜色 | ||
SetSettingGammaOverride | 覆盖伽马设置并阻止客户端对其进行更改 | ||
SetValue | 在客户端设置一个全局值,可以从任何地方访问(客户端) | ||
ShowNotification | 使用内置通知系统显示一条通知。 | ||
| function | Subscribe | 订阅事件 | |
Unsubscribe | 退订此特定类和此特定包中所有已订阅的事件,可选择传递函数以仅退订该回调 |


CopyToClipboard
复制文本到剪贴板
Client.CopyToClipboard(text)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | text | Required parameter | No description provided |


Disconnect
断开与服务器的连接
Client.Disconnect()


GetActorsInRadius
返回指定半径内的 Actor
local ret = Client.GetActorsInRadius(location, radius, only_classes?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Vector | location | Required parameter | 搜索的中心位置 |
| number | radius | Required parameter | 搜索半径 |
| table of string | only_classes? | [] | 仅返回这些类的 Actor(传入空数组以获取所有类) |
Returns
| Type | Description |
|---|---|
| table of Base Actor | 在半径内找到的 Actor 列表 |


GetAllValuesKeys
获取所有值键的列表
local ret = Client.GetAllValuesKeys()


GetConnectedServerIP
获取当前连接的服务器 IP:Port
local ret = Client.GetConnectedServerIP()
Returns
| Type | Description |
|---|---|
| string | No description provided |


GetEntityByID
返回指定 ID 的实体
local ret = Client.GetEntityByID(entity_id)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| integer | entity_id | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| Base Entity or nil | 实体 |


GetFrameTime
获取当前的帧时间
local ret = Client.GetFrameTime()
Returns
| Type | Description |
|---|---|
| float | 帧时间 |


GetLanguage
获取客户端当前的语言
local ret = Client.GetLanguage()
Returns
| Type | Description |
|---|---|
| string | 语言代码 |


GetLocalPlayer
获取本地玩家
local ret = Client.GetLocalPlayer()
Returns
| Type | Description |
|---|---|
| Player | 本地玩家 |


GetLogLevel
返回当前的日志级别
local ret = Client.GetLogLevel()
Returns
| Type | Description |
|---|---|
| integer | 日志级别 |


GetMap
返回当前地图
local ret = Client.GetMap()
Returns
| Type | Description |
|---|---|
| string | 当前地图 |


GetNearClipPlane
获取近裁剪面的值
local ret = Client.GetNearClipPlane()
Returns
| Type | Description |
|---|---|
| float | No description provided |
See also SetNearClipPlane.


GetPackages
返回当前运行的包列表
local ret = Client.GetPackages(package_type_filter?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| PackageType | package_type_filter? | PackageType.All | 要返回的包类型。默认返回所有类型。 |


GetTime
获取毫秒级 Unix 时间戳
local ret = Client.GetTime()
Returns
| Type | Description |
|---|---|
| integer | unix 时间戳 |


GetValue
获取指定键的值
local ret = Client.GetValue(key, fallback)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | key | Required parameter | No description provided |
| any | fallback | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| any | 键对应的值,若键不存在则返回备用值 |
See also GetAllValuesKeys, SetValue.


IsPackageLoaded
返回指定的包当前是否已加载
local ret = Client.IsPackageLoaded(package_name)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | package_name | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| boolean | 包是否已加载 |


OpenEscapeMenu
打开 Esc 菜单
Client.OpenEscapeMenu(open_settings?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | open_settings? | false | 如果为 true,将直接打开设置标签页 |


SetDebugEnabled
启用/禁用调试设置以及允许使用客户端控制台
Client.SetDebugEnabled(enable_debug)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | enable_debug | Required parameter | No description provided |


SetEscapeMenuText
设置 Esc 菜单的文本
Client.SetEscapeMenuText(text)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | text | Required parameter | 文本中支持使用 <h1>、<h2>、<h3> 和 <strong> 标签。 |
Client.SetEscapeMenuText Examples
Adding customized texts
Client.SetEscapeMenuText([[
<h1>Header 1</>
<h2>Header 2</>
<h3>Header 3</>
<strong>Strong</>
Normal Text
]])


SetHighlightColor
更改指定索引处高亮 Actor 的高亮颜色。乘以 5(或更多)可获得发光效果。HighlightMode.Always将始终可见,即使在墙后也是如此HighlightMode.OnlyHidden仅在墙后时可见HighlightMode.OnlyVisible仅在不在墙后时可见
注:你最多只能拥有 3 个不同的索引(0、1 或 2)。
Client.SetHighlightColor(highlight_color, index, mode?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Color | highlight_color | Required parameter | No description provided |
| integer | index | Required parameter | No description provided |
| HighlightMode | mode? | HighlightMode.Always | No description provided |


SetNearClipPlane
设置近裁剪面
Client.SetNearClipPlane(near_clip_plane)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| float | near_clip_plane | Required parameter | No description provided |
See also GetNearClipPlane.


SetOutlineColor
更改指定索引处描边 Actor 的描边颜色。乘以 5(或更多)可获得发光效果。
注:你最多只能拥有 3 个不同的索引(0、1 或 2),并且游戏默认使用的描边颜色索引为0(在与物品互动时)。
Client.SetOutlineColor(outline_color, index?, thickness?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| Color | outline_color | Required parameter | No description provided |
| integer | index? | 0 | No description provided |
| float | thickness? | 2 | No description provided |


SetSettingGammaOverride
覆盖伽马设置并阻止客户端对其进行更改
Client.SetSettingGammaOverride(override, new_gamma?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| boolean | override | Required parameter | 是否覆盖伽马设置 |
| float or nil | new_gamma? | 1.0 | 覆盖时的新伽马值 |


SetValue
在客户端设置一个全局值,可以从任何地方访问(客户端)
请参考实体值进一步了解
Client.SetValue(key, value)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | key | Required parameter | 键 |
| any | value | Required parameter | 值 |
See also GetAllValuesKeys, GetValue, ValueChange.


ShowNotification
使用内置通知系统显示一条通知。
Client.ShowNotification(text, notification_type?, add_to_notification_list?, duration?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | text | Required parameter | No description provided |
| NotificationType | notification_type? | NotificationType.Info | No description provided |
| boolean | add_to_notification_list? | true | 是否将此通知添加到通知列表中(可通过右上角铃铛图标查看) |
| float | duration? | 10 | 通知显示的持续时间(秒) |


Subscribe
订阅事件
local ret = Client.Subscribe(event_name, callback)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | No description provided |
| function | callback | Required parameter | No description provided |
Returns
| Type | Description |
|---|---|
| function | 函数回调本身 |


Unsubscribe
退订此特定类和此特定包中所有已订阅的事件,可选择传递函数以仅退订该回调
Client.Unsubscribe(event_name, callback?)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | event_name | Required parameter | No description provided |
| function | callback? | nil | No description provided |
🚀 事件
| Name | Description | |
|---|---|---|
LanguageChange | 当客户端语言改变时调用 | |
SpawnLocalPlayer | 当本地玩家生成时调用(紧接着游戏加载完成后) | |
Tick | 每帧调用。请勿滥用 | |
ValueChange | 当通过 Client.SetValue() 或 Server.SetValue()(用于同步值)更改值时触发 | |
WindowFocusChange | 当游戏获得/失去焦点时调用 |

LanguageChange
当客户端语言改变时调用
Client.Subscribe("LanguageChange", function(language)
-- LanguageChange was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | language | 新的语言代码 |

SpawnLocalPlayer
当本地玩家生成时调用(紧接着游戏加载完成后)
Client.Subscribe("SpawnLocalPlayer", function(local_player)
-- SpawnLocalPlayer was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| Player | local_player | No description provided |

Tick
每帧调用。请勿滥用
Client.Subscribe("Tick", function(delta_time)
-- Tick was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| float | delta_time | No description provided |

ValueChange
当通过Client.SetValue()或Server.SetValue()(用于同步值)更改值时触发
Client.Subscribe("ValueChange", function(key, value)
-- ValueChange was called
end)
See also SetValue, Server.SetValue().

WindowFocusChange
当游戏获得/失去焦点时调用
Client.Subscribe("WindowFocusChange", function(is_focused)
-- WindowFocusChange was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| boolean | is_focused | 是否获得焦点 |