奇怪的报错
function examine() {if (hasitem(itemList, 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, ["拥有者:" + 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, 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, ["拥有者:" + 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` 确保在 `)` 前正确关闭。
您也可以使用代码编辑器的自动格式化功能来帮助检查和修正括号匹配问题。希望这能解决您的问题。
@屑空白 看一下 你确定是这些代码有问题? 指令凋灵 发表于 2024-6-7 22:16
你确定是这些代码有问题?
报的语法错误 指令凋灵 发表于 2024-6-7 22:16
你确定是这些代码有问题?
import那里 用VSCode检查了下语法,应该是import这段的问题
页: [1]