EnderTrekker 发表于 2024-8-11 13:22:11

这怎么改啊 (sapi)

本帖最后由 qzusergjf 于 2024-8-11 14:11 编辑

为什么老是报错呢
import { world } from '@minecraft/server';

// 定义一个对象来存储玩家的坐标点
const savedLocations = {};

// 保存玩家坐标点的函数
function savePlayerLocation(player) {
    const location = {
      x: player.location.x,
      y: player.location.y,
      z: player.location.z,
      dimension: player.dimension.name
    };
    // 使用玩家名作为键来存储坐标
    savedLocations = location;
}

// 传送玩家到保存的坐标点并删除坐标点信息的函数
function teleportAndRemoveSavedLocation(player) {
    const location = savedLocations;
    if (location) {
      // 获取正确的维度对象
      const dimension = world.getDimension(location.dimension);
      // 执行传送
      player.teleport(dimension, { x: location.x, y: location.y, z: location.z });
    } else {
    }
    // 删除保存的坐标点信息
    delete savedLocations;
}

// 监听玩家聊天事件
world.afterEvents.chatSend.subscribe((event) => {
    const { message } = event;
    const player = event.sender;

    // 玩家输入“开启”时保存当前坐标点
    if (message === "开启") {
      savePlayerLocation(player);
      // 执行开启功能的相关命令
      world.runCommand('function jh');
    }

    // 玩家输入“关闭”时传送到保存的坐标点并删除坐标点信息
    if (message === "关闭") {
      teleportAndRemoveSavedLocation(player);
      // 执行关闭功能的相关命令
      world.runCommand('function gb');
    }
});
报错内容
-我的世界 | actor_definitions | /storage/emulated/0/Android/data/com.mojang.minecraftpe/files/games/com.mojang/minecraftWorlds/xUW4ZlhxIAA=/behavior_packs/灵魂出窍[V1 | pa:npcts | minecraft:entity | components | pa:npcts's Component minecraft:transformed was not parsed.

-Line: 70 - Invalid lang file format. New line character was found while parsing key: '//items'.

-Line: 75 - Invalid lang file format. New line character was found while parsing key: '//spawn eggs//'.

-Line: 113 - Invalid lang file format. New line character was found while parsing key: '//entities//'.

-Line: 151 - Invalid lang file format. New line character was found while parsing key: '//new furni//'.

-Line: 189 - Invalid lang file format. New line character was found while parsing key: '///'.

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: selector_area | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: settings.selector_stack_panel | UI Control: world_selector_pane | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/selector_area/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/settings.selector_stack_panel/world_selector_pane/game_button | Expected variable not found in ancestor tree: '$education_edition_china'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: selector_area | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: settings.selector_stack_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/selector_area/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/settings.selector_stack_panel/addons_selector_panel | Expected variable not found in ancestor tree: '$education_edition_china'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: world_sections | UI Control Key: game_section@world_section.game_section | Expected variable not found in ancestor tree: '$ios'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/available_packs_section/empty_panel/to_store_button | JSON UI parse failure: Must define a binding name!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/available_packs_section/empty_panel/to_store_button | Data bindings must have at least one property to bind!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/unowned_packs_title_button | JSON UI parse failure: Must define a binding name!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/unowned_packs_title_button | Data bindings must have at least one property to bind!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: addon_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_vi

指令凋灵 发表于 2024-8-11 13:22:12

因为连不上npm官网,只修了一点点bug

指令凋灵 发表于 2024-8-11 13:25:14

本帖最后由 指令凋灵 于 2024-8-11 13:26 编辑

sapi没错(sapi报错是以开头的)

蝙蝠侠艾登 发表于 2024-8-11 13:32:20

在文件中,出现了换行字符,这不符合JSON格式的要求。需要检查并修正这些行,确保它们是有效的JSON格式。

EnderTrekker 发表于 2024-8-11 13:42:51

指令凋灵 发表于 2024-8-11 13:25
sapi没错(sapi报错是以开头的)

ui的问题是吧,问题是我文件里也没有有关ui的啊?

EnderTrekker 发表于 2024-8-11 13:44:14

指令凋灵 发表于 2024-8-11 13:25
sapi没错(sapi报错是以开头的)

一开始没改这个文件的时候没报错,改了以后接着报错

Sakarwei 发表于 2024-8-11 13:51:19

一、我没看到 错误日志 Script API 的报错。
二、翻译文件的注释是“#”开头。
三、如果你制作的包没有 UI 文件的,那么涉及 UI 的报错可能是其它材质包的。因为 MC 的错误日志(好像是)将所有包的错误收集到一份文件里面。

EnderTrekker 发表于 2024-8-11 13:52:41

Sakarwei 发表于 2024-8-11 13:51
一、我没看到 错误日志 Script API 的报错。
二、翻译文件的注释是“#”开头。
三、如果你制作的包没有 UI...

json的文件不是//吗?

EnderTrekker 发表于 2024-8-11 13:53:23

Sakarwei 发表于 2024-8-11 13:51
一、我没看到 错误日志 Script API 的报错。
二、翻译文件的注释是“#”开头。
三、如果你制作的包没有 UI...

而且没加其他模组

EnderTrekker 发表于 2024-8-11 15:22:34

指令凋灵 发表于 2024-8-11 13:22
因为连不上npm官网,只修了一点点bug

但是还是报错了
-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: selector_area | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: settings.selector_stack_panel | UI Control: world_selector_pane | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/selector_area/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/settings.selector_stack_panel/world_selector_pane/game_button | Expected variable not found in ancestor tree: '$education_edition_china'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: selector_area | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: settings.selector_stack_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/selector_area/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/settings.selector_stack_panel/addons_selector_panel | Expected variable not found in ancestor tree: '$education_edition_china'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: world_sections | UI Control Key: game_section@world_section.game_section | Expected variable not found in ancestor tree: '$ios'

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/available_packs_section/empty_panel/to_store_button | JSON UI parse failure: Must define a binding name!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/available_packs_section/empty_panel/to_store_button | Data bindings must have at least one property to bind!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/unowned_packs_title_button | JSON UI parse failure: Must define a binding name!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: level_texture_pack_section | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/level_texture_pack_section/unowned_packs_title_button | Data bindings must have at least one property to bind!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: addon_section | UI Control: available_packs_section | UI Control: empty_panel | On Control Path: /screen_world_controls_and_settings/variables_button_mappings_and_controls/safezone_screen_matrix/inner_matrix/safezone_screen_panel/root_screen_panel/stack_panel/content_panel/container/settings_common.dialog_content/content_area/control/scrolling_panel/scroll_touch/scroll_view/panel/background_and_viewport/scrolling_view_port/scrolling_content/packs_sections/addon_section/available_packs_section/empty_panel/to_store_button | JSON UI parse failure: Must define a binding name!

-UI Control: screen_world_controls_and_settings | UI Control: variables_button_mappings_and_controls | UI Control: safezone_screen_matrix | UI Control: inner_matrix | UI Control: safezone_screen_panel | UI Control: root_screen_panel | UI Control: stack_panel | UI Control: content_panel | UI Control: container | UI Control: settings_common.dialog_content | UI Control: content_area | UI Control: control | UI Control: scrolling_panel | UI Control: scroll_touch | UI Control: scroll_view | UI Control: panel | UI Control: background_and_viewport | UI Control: scrolling_view_port | UI Control: scrolling_content | UI Control: packs_sections | UI Control: addon_section | UI Control: available_packs_section | UI Control: empty_panel
页: [1]2
查看完整版本: 这怎么改啊 (sapi)