手册:HTML-based UI/Core
本条目仍需完善。 |
此页面内容仍处于开发阶段,随时有可能发生变更,请自行关注本页面 |
Core
包是 HbUI 已开放的核心接口包,其中包含的子包如下:
scripting 编辑
core.scripting
接口用于与脚本进行对接。
属性 编辑
无
方法 编辑
triggerEvent (Data) 编辑
参数 编辑
名称 | 类型 | 描述 |
---|---|---|
Data | 字符串 | 此字符串将会被发送至本地脚本的 "minecraft:ui_event" 事件 |
示例 编辑
向本地脚本端发送 "SendThisDataToTheScript"
字符串
let scriptInterface = undefined;
engine.on("facet:updated:scripting", function(interface) {
scriptInterface = interface;
});
engine.trigger("facet:request", ["scripting"]);
scriptInterface.triggerEvent("SendThisDataToTheScript");
locale 编辑
core.locale
接口用于获取附加包中已加载的本地化文本以及格式化时间文本。
属性 编辑
locale 编辑
当前的语言地区代码(如:zh_CN
)
方法 编辑
translate(LocaleTextKey) 编辑
参数 编辑
名称 | 类型 | 描述 |
---|---|---|
LocaleTextKey | 字符串 | 需要被转换的本地化键名 |
返回值 编辑
返回传入的本地化键名对应游戏当前所设定语言的文本。
示例 编辑
获取键名为 "ui.test.hello_world"
在当前语言下所对应的文本