猫史档案馆


有大佬能帮我找下这段错误吗?

用户:BlackShadowBlackShadow查看:1 回复:3 评论:1 创建时间:2023-04-10T18:50:24


world.onChat(async({ entity, message }) => {
    if (message === '/tp') }
        const gethc = await entity.player.dialog({
            type: Box3DialogType.SELECT, 
            content: "请选择传送的地方",
            title:"传送系统", 
            options: ["出生岛","家园","资源"],
        })
        if(!gethc)return;
        if(gethc.index==0){
            entity.position.set(1,1,1)   
        }
        if(gethc.index==1){
            entity.player.dialog({
            type: Box3DialogType.TEXT, 
            content: "请稍后",
            title:"家园", 
            })
        }
        if(gethc.index==2){
            entity.player.dialog({
            type: Box3DialogType.TEXT, 
            content: "资源区正在加载中",
            title:"资源1区", 
            })
        }

如题emotion_编程猫_厉害了


回复

上一页1 页 / 共 1下一页
HIM_PETERHIM_PETER

world.onChat(async({ entity, message }) => {
    if (message === '/tp') {
        const gethc = await entity.player.dialog({
            type: Box3DialogType.SELECT, 
            content: "请选择传送的地方",
            title:"传送系统", 
            options: ["出生岛","家园","资源"],
        })
        if(!gethc)return;
        if(gethc.index==0){
            entity.position.set(1,1,1)   
        }
        if(gethc.index==1){
            entity.player.dialog({
            type: Box3DialogType.TEXT, 
            content: "请稍后",
            title:"家园", 
            })
        }
        if(gethc.index==2){
            entity.player.dialog({
            type: Box3DialogType.TEXT, 
            content: "资源区正在加载中",
            title:"资源1区", 
            })
        }
    }
})

点赞1


评论


𝙲ℴ𝗌𝔦𝒹ₑ𝑟𝙲ℴ𝗌𝔦𝒹ₑ𝑟

为什么不用match()

点赞0


评论


边城过客边城过客

这个简单,这段代码缺少一个左大括号 {,应该改为:

world.onChat(async ({ entity, message }) => {
    if (message === '/tp') {
        const gethc = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            content: "请选择传送的地方",
            title: "传送系统",
            options: ["出生岛", "家园", "资源"],
        })
        if (!gethc) return;
        if (gethc.index == 0) {
            entity.position.set(1, 1, 1)
        }
        if (gethc.index == 1) {
            entity.player.dialog({
                type: Box3DialogType.TEXT,
                content: "请稍后",
                title: "家园",
            })
        }
        if (gethc.index == 2) {
            entity.player.dialog({
                type: Box3DialogType.TEXT,
                content: "资源区正在加载中",
                title: "资源1区",
            })
        }
    }
})

点赞1


评论