跳至正文
版本:bleeding-edge 🩸

⌨️ 客户端

客户端存在的静态类。

🗿Static ClassClient Only🧑‍💻API Source

🗿 静态函数​

ReturnsNameDescription
CopyToClipboard复制文本到剪贴板
Disconnect断开与服务器的连接
table of Base ActorGetActorsInRadius返回指定半径内的 Actor
table of stringGetAllValuesKeys获取所有存储值的键名列表
stringGetConnectedServerIP获取当前连接的服务器 IP:Port
Base Entity or nilGetEntityByID返回指定 ID 的实体
floatGetFrameTime获取当前的帧时间
stringGetLanguage获取客户端当前的语言
PlayerGetLocalPlayer获取本地玩家
integerGetLogLevel返回当前的日志级别
stringGetMap返回当前地图包的名称
floatGetNearClipPlane获取近裁剪面的值
table of tableGetPackages返回当前运行的包列表
tableGetSettings获取本地玩家的游戏设置
integerGetTime获取毫秒级 Unix 时间戳
anyGetValue获取指定键的值
booleanIsPackageLoaded返回指定的包当前是否已加载
OpenEscapeMenu打开 Esc 菜单
SetDebugEnabled启用/禁用调试设置以及允许使用客户端控制台
SetEscapeMenuText设置 Esc 菜单的文本
SetHighlightColor更改指定索引处高亮 Actor 的高亮颜色
SetNearClipPlane设置近裁剪面
SetOutlineColor更改指定索引处描边 Actor 的描边颜色
SetSettingGammaOverride覆盖伽马设置并阻止客户端对其进行更改
SetValue在客户端设置一个全局值,可以从任何地方访问(客户端)
ShowNotification使用内置通知系统显示一条通知。
functionSubscribe订阅事件
Unsubscribe退订此特定类和此特定包中所有已订阅的事件,可选择传递函数以仅退订该回调

Optimal

CopyToClipboard​

复制文本到剪贴板
Client.CopyToClipboard(text)

Parameters

TypeParameterDefaultDescription
stringtext Required parameter 要复制的文本

Slow

Disconnect​

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

Moderate

GetActorsInRadius​

返回指定半径内的 Actor
local ret = Client.GetActorsInRadius(location, radius, only_classes?)

Parameters

TypeParameterDefaultDescription
Vectorlocation Required parameter 搜索的中心位置
numberradius Required parameter 搜索半径
table of stringonly_classes?[]
仅返回这些类的 Actor(传入空数组以获取所有类)

Returns

TypeDescription
table of Base Actor在半径内找到的 Actor 列表

Moderate

GetAllValuesKeys​

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

Returns

TypeDescription
table of string包含所有存储值键名的列表

See also GetValue, SetValue.


Optimal

GetConnectedServerIP​

获取当前连接的服务器 IP:Port
local ret = Client.GetConnectedServerIP()

Returns

TypeDescription
string当前已连接服务器的 IP:端口

Moderate

GetEntityByID​

返回指定 ID 的实体
local ret = Client.GetEntityByID(entity_id)

Parameters

TypeParameterDefaultDescription
integerentity_id Required parameter 实体 ID

Returns

TypeDescription
Base Entity or nil实体

Optimal

GetFrameTime​

获取当前的帧时间
local ret = Client.GetFrameTime()

Returns

TypeDescription
float帧时间

Optimal

GetLanguage​

获取客户端当前的语言
local ret = Client.GetLanguage()

Returns

TypeDescription
string语言代码

Optimal

GetLocalPlayer​

获取本地玩家
local ret = Client.GetLocalPlayer()

Returns

TypeDescription
Player本地玩家

Optimal

GetLogLevel​

返回当前的日志级别
local ret = Client.GetLogLevel()

Returns

TypeDescription
integer日志级别

Optimal

GetMap​

返回当前地图包的名称
local ret = Client.GetMap()

Returns

TypeDescription
string当前地图

Optimal

GetNearClipPlane​

获取近裁剪面的值
local ret = Client.GetNearClipPlane()

Returns

TypeDescription
float近裁切面的值

See also SetNearClipPlane.


Slow

GetPackages​

返回当前运行的包列表
local ret = Client.GetPackages(package_type_filter?)

Parameters

TypeParameterDefaultDescription
PackageTypepackage_type_filter?PackageType.All
要返回的包类型。默认返回所有类型。

Returns

TypeDescription
table of table包的数据列表 with this format

Slow

GetSettings​

获取本地玩家的游戏设置
local ret = Client.GetSettings()

Returns

TypeDescription
table当前设置 with this format

Optimal

GetTime​

获取毫秒级 Unix 时间戳
local ret = Client.GetTime()

Returns

TypeDescription
integerunix 时间戳

Moderate

GetValue​

获取指定键的值
local ret = Client.GetValue(key, fallback)

Parameters

TypeParameterDefaultDescription
stringkey Required parameter 键
anyfallback Required parameter 当键名不存在时返回的值

Returns

TypeDescription
any指定键的值,若键不存在则返回回退值

See also GetAllValuesKeys, SetValue.


Moderate

IsPackageLoaded​

返回指定的包当前是否已加载
local ret = Client.IsPackageLoaded(package_name)

Parameters

TypeParameterDefaultDescription
stringpackage_name Required parameter 包文件夹名称

Returns

TypeDescription
boolean包是否已加载

Optimal

OpenEscapeMenu​

打开 Esc 菜单
Client.OpenEscapeMenu(open_settings?)

Parameters

TypeParameterDefaultDescription
booleanopen_settings?false
如果为 true,将直接打开设置标签页

Moderate

SetDebugEnabled​

启用/禁用调试设置以及允许使用客户端控制台
Client.SetDebugEnabled(enable_debug)

Parameters

TypeParameterDefaultDescription
booleanenable_debug Required parameter 是否允许使用调试设置和客户端控制台

Moderate

SetEscapeMenuText​

设置 Esc 菜单的文本
Client.SetEscapeMenuText(text)

Parameters

TypeParameterDefaultDescription
stringtext 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
]])

Optimal

SetHighlightColor​

更改指定索引处高亮 Actor 的高亮颜色。乘以 5(或更多)可获得发光效果。

HighlightMode.Always 将始终可见,即使在墙后也是如此
HighlightMode.OnlyHidden 仅在墙后时可见
HighlightMode.OnlyVisible 仅在不在墙后时可见

注:你最多只能拥有 3 个不同的索引(0、1 或 2)。
Client.SetHighlightColor(highlight_color, index, mode?)

Parameters

TypeParameterDefaultDescription
Colorhighlight_color Required parameter 使用的颜色
integerindex Required parameter 高亮槽位索引(0 到 2)
HighlightModemode?HighlightMode.Always
高亮何时可见

Optimal

SetNearClipPlane​

设置近裁剪面
Client.SetNearClipPlane(near_clip_plane)

Parameters

TypeParameterDefaultDescription
floatnear_clip_plane Required parameter 新的近裁切面

See also GetNearClipPlane.


Optimal

SetOutlineColor​

更改指定索引处描边 Actor 的描边颜色。乘以 5(或更多)可获得发光效果。

注:你最多只能拥有 3 个不同的索引(0、1 或 2),并且游戏默认使用的描边颜色索引为 0(在与物品互动时)。
Client.SetOutlineColor(outline_color, index?, thickness?)

Parameters

TypeParameterDefaultDescription
Coloroutline_color Required parameter 使用的颜色
integerindex?0
轮廓槽位索引(0 到 2)
floatthickness?2
线条粗细

Optimal

SetSettingGammaOverride​

覆盖伽马设置并阻止客户端对其进行更改
Client.SetSettingGammaOverride(override, new_gamma?)

Parameters

TypeParameterDefaultDescription
booleanoverride Required parameter 是否覆盖伽马设置
float or nilnew_gamma?1.0
覆盖时的新伽马值

Moderate

SetValue​

在客户端设置一个全局值,可以从任何地方访问(客户端)

请参考实体值进一步了解
Client.SetValue(key, value)

Parameters

TypeParameterDefaultDescription
stringkey Required parameter 键
anyvalue Required parameter 明度

See also GetAllValuesKeys, GetValue, ValueChange.


Moderate

ShowNotification​

使用内置通知系统显示一条通知。
Client.ShowNotification(text, notification_type?, add_to_notification_list?, duration?)

Parameters

TypeParameterDefaultDescription
stringtext Required parameter 通知的文本
NotificationTypenotification_type?NotificationType.Info
通知的样式
booleanadd_to_notification_list?true
是否将此通知添加到通知列表中(可通过右上角铃铛图标查看)
floatduration?10
通知显示的持续时间(秒)

Optimal

Subscribe​

订阅事件
local ret = Client.Subscribe(event_name, callback)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter 事件的名称
functioncallback Required parameter 要被调用的函数

Returns

TypeDescription
function函数回调本身

Optimal

Unsubscribe​

退订此特定类和此特定包中所有已订阅的事件,可选择传递函数以仅退订该回调
Client.Unsubscribe(event_name, callback?)

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter 事件的名称
functioncallback?nil
要被调用的函数

🚀 事件​

NameDescription
LanguageChange当客户端语言改变时调用
SpawnLocalPlayer当本地玩家生成时调用(紧接着游戏加载完成后)
Tick每帧调用。请勿滥用
ValueChange当通过 Client.SetValue() 或 Server.SetValue()(用于同步值)更改值时触发
WindowFocusChange当游戏获得/失去焦点时调用

LanguageChange​

当客户端语言改变时调用
Client.Subscribe("LanguageChange", function(language)
-- LanguageChange was called
end)

Arguments

TypeArgumentDescription
stringlanguage新的语言代码

SpawnLocalPlayer​

当本地玩家生成时调用(紧接着游戏加载完成后)
Client.Subscribe("SpawnLocalPlayer", function(local_player)
-- SpawnLocalPlayer was called
end)

Arguments

TypeArgumentDescription
Playerlocal_player本地玩家

Tick​

每帧调用。请勿滥用
Client.Subscribe("Tick", function(delta_time)
-- Tick was called
end)

Arguments

TypeArgumentDescription
floatdelta_time自上一帧以来经过的秒数

ValueChange​

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

Arguments

TypeArgumentDescription
stringkey发生改变的键
anyvalue新值

See also SetValue, Server.SetValue().


WindowFocusChange​

当游戏获得/失去焦点时调用
Client.Subscribe("WindowFocusChange", function(is_focused)
-- WindowFocusChange was called
end)

Arguments

TypeArgumentDescription
booleanis_focused是否获得焦点