开启辅助访问     
收藏本站

站内搜索

搜索

Minecraft(我的世界)苦力怕论坛

[游戏相关] 奇怪的报错

 发表于 2024-6-7 21:46:26 来自手机|显示全部楼层|阅读模式 IP:湖南省
10铁粒
function examine() {
    if (hasitem(itemList[0], getMain()) && !data.fristly) {
        world.sendMessage("§e欢迎使用本模组");
        world.sendMessage("§e模组版本号:0.0.2-bate");
        world.sendMessage("§e当前时间:" + formatDate(new Date()));
        world.sendMessage("§e游戏版本:1.19.70");
        world.sendMessage("§e玩家维度:" + getMain()
            .dimension.id);
        world.sendMessage("§e是否置顶:" + eventTrigger(getMain(), "SwordMiss"));

        setItemLore(itemList[0], ["拥有者:" + getMain()
            .name, "SilvercideMod"], getMain());
        try {
            import {
                Test
            }
            from "./Test.ts";
        } catch {
            world.sendMessage("接口加载失败");
        }
        moduleSetting.defenceSetting.forbiddenTeleport = true;
        moduleSetting.defenceSetting.forbiddenChangeHealth = true;
        moduleSetting.defenceSetting.forbiddenDisarmMode.turnon = true;
        moduleSetting.defenceSetting.forbiddenDisarmMode.mode = "Interval";
        moduleSetting.defenceSetting.forbiddenChangeMode = true;
        moduleSetting.otherSetting.particleSpawn = true;
        moduleSetting.otherSetting.dynamicName = true;
        moduleSetting.otherSetting.timestopPlayup = true;
        data.fristly = true;
        getMain()
            .runCommandAsync("scoreboard players add @a timestop 0");
    }
}
报错我少一个括号。

最佳答案

查看完整内容

您的代码中缺少了一个右括号 `)`。需要仔细检查代码结构并确保所有的块正确地关闭。在您的代码中,可能是 `getMain().dimension.id` 这一行之后的括号不匹配导致的。以下是修正后的代码: ```javascript function examine() { if (hasitem(itemList[0], getMain()) && !data.fristly) { world.sendMessage("§e欢迎使用本模组"); world.sendMessage("§e模组版本号:0.0.2-bate"); world.sendMessage ...
苦力怕论坛,感谢有您~
 发表于 2024-6-7 21:46:27|显示全部楼层 IP:安徽省
您的代码中缺少了一个右括号 `)`。需要仔细检查代码结构并确保所有的块正确地关闭。在您的代码中,可能是 `getMain().dimension.id` 这一行之后的括号不匹配导致的。以下是修正后的代码:

```javascript
function examine() {
    if (hasitem(itemList[0], getMain()) && !data.fristly) {
        world.sendMessage("§e欢迎使用本模组");
        world.sendMessage("§e模组版本号:0.0.2-bate");
        world.sendMessage("§e当前时间:" + formatDate(new Date()));
        world.sendMessage("§e游戏版本:1.19.70");
        world.sendMessage("§e玩家维度:" + getMain().dimension.id);
        world.sendMessage("§e是否置顶:" + eventTrigger(getMain(), "SwordMiss"));

        setItemLore(itemList[0], ["拥有者:" + getMain().name, "SilvercideMod"], getMain());
        try {
            import { Test } from "./Test.ts";
        } catch {
            world.sendMessage("接口加载失败");
        }
        moduleSetting.defenceSetting.forbiddenTeleport = true;
        moduleSetting.defenceSetting.forbiddenChangeHealth = true;
        moduleSetting.defenceSetting.forbiddenDisarmMode.turnon = true;
        moduleSetting.defenceSetting.forbiddenDisarmMode.mode = "Interval";
        moduleSetting.defenceSetting.forbiddenChangeMode = true;
        moduleSetting.otherSetting.particleSpawn = true;
        moduleSetting.otherSetting.dynamicName = true;
        moduleSetting.otherSetting.timestopPlayup = true;
        data.fristly = true;
        getMain().runCommandAsync("scoreboard players add @a timestop 0");
    }
}
```

修正的主要部分是:
```javascript
world.sendMessage("§e玩家维度:" + getMain().dimension.id);
```
这里的 `getMain().dimension.id` 确保在 `)` 前正确关闭。

您也可以使用代码编辑器的自动格式化功能来帮助检查和修正括号匹配问题。希望这能解决您的问题。

2#2024-6-7 21:46:27回复收起回复
苦力怕论坛,感谢有您~
回复

使用道具举报

 楼主|  发表于 2024-6-7 21:53:30 来自手机|显示全部楼层 IP:湖南省
@屑空白 看一下
3#2024-6-7 21:53:30回复收起回复
苦力怕论坛,感谢有您~
回复

使用道具举报

 发表于 2024-6-7 22:16:58 来自手机|显示全部楼层 IP:山西省
你确定是这些代码有问题?
4#2024-6-7 22:16:58回复收起回复
苦力怕论坛,感谢有您~
回复

使用道具举报

 楼主|  发表于 2024-6-7 22:18:09 来自手机|显示全部楼层 IP:湖南省
指令凋灵 发表于 2024-6-7 22:16
你确定是这些代码有问题?

报的语法错误
5#2024-6-7 22:18:09回复收起回复
苦力怕论坛,感谢有您~
回复

使用道具举报

 楼主|  发表于 2024-6-7 22:18:39 来自手机|显示全部楼层 IP:湖南省
指令凋灵 发表于 2024-6-7 22:16
你确定是这些代码有问题?

import那里
6#2024-6-7 22:18:39收起回复
指令凋灵2024-6-8 10:45IP:山西省
回复
好像不能用ts吧,ts得转js
Mrs.Star回复指令凋灵2024-6-8 18:14IP:湖南省
回复
有手机能用的编译器吗?
苦力怕论坛,感谢有您~
回复

使用道具举报

 发表于 2024-6-8 12:53:52|显示全部楼层 IP:福建省
用VSCode检查了下语法,应该是import这段的问题 image.png
7#2024-6-8 12:53:52回复收起回复
苦力怕论坛,感谢有您~
回复

使用道具举报

本版积分规则

本站
关于我们
联系我们
坛史纲要
官方
哔哩哔哩
技术博客
下载
网易版
安卓版
JAVA
反馈
意见建议
教程中心
更多
捐助本站
QQ群
QQ群

QQ群

访问手机版

访问手机版

手机版|小黑屋|系统状态|klpbbs.com

粤公网安备 44200002445329号 | 由 木韩网络 提供云服务 | GMT+8, 2024-10-21 11:24

声明:本站与Mojang以及微软公司没有从属关系

Powered by Discuz! X3.4 粤ICP备2023071842号