跳至正文
版本:latest - a1.147.x ⚖️

⌨️ 客户端

客户端存在的静态类。

🗿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!

🗿 静态函数

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返回当前运行的包列表
integerGetTime获取毫秒级 Unix 时间戳
anyGetValue获取指定键的值
booleanIsPackageLoaded返回指定的包当前是否已加载
OpenEscapeMenu打开 Esc 菜单
SetDebugEnabled启用/禁用调试设置以及允许使用客户端控制台
SetEscapeMenuText设置 Esc 菜单的文本
SetHighlightColor更改指定索引处高亮 Actor 的高亮颜色
SetNearClipPlane设置近裁剪面
SetOutlineColor更改指定索引处描边 Actor 的描边颜色
SetSettingGammaOverride覆盖伽马设置并阻止客户端对其进行更改
SetValue在客户端设置一个全局值,可以从任何地方访问(客户端)
ShowNotification使用内置通知系统显示一条通知。
functionSubscribe订阅事件
Unsubscribe退订此特定类和此特定包中所有已订阅的事件,可选择传递函数以仅退订该回调

CopyToClipboard

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

Parameters

TypeParameterDefaultDescription
stringtext Required parameter No description provided

Disconnect

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

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 列表

GetAllValuesKeys

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

Returns

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

See also GetValue, SetValue.


GetConnectedServerIP

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

Returns

TypeDescription
stringNo description provided

GetEntityByID

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

Parameters

TypeParameterDefaultDescription
integerentity_id Required parameter No description provided

Returns

TypeDescription
Base Entity or nil实体

GetFrameTime

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

Returns

TypeDescription
float帧时间

GetLanguage

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

Returns

TypeDescription
string语言代码

GetLocalPlayer

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

Returns

TypeDescription
Player本地玩家

GetLogLevel

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

Returns

TypeDescription
integer日志级别

GetMap

返回当前地图
local ret = Client.GetMap()

Returns

TypeDescription
string当前地图

GetNearClipPlane

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

Returns

TypeDescription
floatNo description provided

See also SetNearClipPlane.


GetPackages

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

Parameters

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

Returns

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

GetTime

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

Returns

TypeDescription
integerunix 时间戳

GetValue

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

Parameters

TypeParameterDefaultDescription
stringkey Required parameter No description provided
anyfallback Required parameter No description provided

Returns

TypeDescription
any键对应的值,若键不存在则返回备用值

See also GetAllValuesKeys, SetValue.


IsPackageLoaded

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

Parameters

TypeParameterDefaultDescription
stringpackage_name Required parameter No description provided

Returns

TypeDescription
boolean包是否已加载

OpenEscapeMenu

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

Parameters

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

SetDebugEnabled

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

Parameters

TypeParameterDefaultDescription
booleanenable_debug Required parameter No description provided

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

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 No description provided
integerindex Required parameter No description provided
HighlightModemode?HighlightMode.Always
No description provided

SetNearClipPlane

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

Parameters

TypeParameterDefaultDescription
floatnear_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

TypeParameterDefaultDescription
Coloroutline_color Required parameter No description provided
integerindex?0
No description provided
floatthickness?2
No description provided

SetSettingGammaOverride

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

Parameters

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

SetValue

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

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

Parameters

TypeParameterDefaultDescription
stringkey Required parameter
anyvalue Required parameter

See also GetAllValuesKeys, GetValue, ValueChange.


ShowNotification

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

Parameters

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

Subscribe

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

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter No description provided
functioncallback Required parameter No description provided

Returns

TypeDescription
function函数回调本身

Unsubscribe

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

Parameters

TypeParameterDefaultDescription
stringevent_name Required parameter No description provided
functioncallback?nil
No description provided

🚀 事件

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_playerNo description provided

Tick

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

Arguments

TypeArgumentDescription
floatdelta_timeNo description provided

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是否获得焦点