猫史档案馆


选项报错了咋办

用户:不喝只因汤的屑嘶令不喝只因汤的屑嘶令查看:5 回复:3 评论:5 创建时间:2022-08-16T23:49:14


const magic = world.querySelector('#传送法阵');
magic.enableInteract  = true;
magic.interactRadius = 12;
magic.interactHint = '法阵';
magic.interactColor = new Box3RGBColor(0,0,1);
magic.onInteract(async({entity}) => {
    const  magic= await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: "法阵",
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},你可以帮我个忙吗?`,
        options: ['矿洞', '太空'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });

    // 如果玩家点击了屏幕其他区域,取消了对话框。
    if(!result || result === null){ 
        entity.player.directMessage('你是在干啥?');
        return; 
    }

    // 判断玩家选了什么选项。
    switch (result.index) {
        case 0:
            // 如果选择了第一项,即:'没问题'
            entity.player.directMessage('作者感到很开心,奖励了你一朵大红花!');
            entity.player.walkSpeed += 114514
            world.say(`${entity.player.name} 帮助了作者,获得了作者的奖励。`)
            break;
        case 1:
            // 如果选择了第二项,即:'现在没空'
            entity.player.directMessage('作者失望地离开了。');
            break;
        default:
            // 注意,使用 switch 分支的时候,不要漏了后面的 break; 
    }

}); 

啊啊啊,我输入这个代码,报错了,谁能教教我咋办?

错误:类别

原因:结果未在评估中定义

焯!!!!!!


回复

上一页1 页 / 共 1下一页
FML饭米粒FML饭米粒

前面

const magic = ...

后面

if(!result...)...

 

人才

点赞0


评论


疏桐_疏桐_

抄API都不带改的()

点赞0


评论


疏桐_疏桐_

const magic = world.querySelector('#传送法阵');
magic.enableInteract  = true;
magic.interactRadius = 12;
magic.interactHint = '法阵';
magic.interactColor = new Box3RGBColor(0,0,1);
magic.onInteract(async({entity}) => {
    const  result = await entity.player.dialog({
        type: Box3DialogType.SELECT,
        title: "法阵",
        titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
        titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
        content: `${entity.player.name},你可以帮我个忙吗?`,
        options: ['矿洞', '太空'],   // 将提供玩家选择的选项放入数组里。
        contentTextColor:  new Box3RGBAColor(0, 0, 0, 1),
        contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1),
        lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
        lookTarget: entity,
    });

 // 如果玩家点击了屏幕其他区域,取消了对话框。
    if(!result || result === null){ 
        entity.player.directMessage('你是在干啥?');
        return; 
    }

    // 判断玩家选了什么选项。
    switch (result.index) {
        case 0:
            // 如果选择了第一项,即:'没问题'
            entity.player.directMessage('作者感到很开心,奖励了你一朵大红花!');
            entity.player.walkSpeed += 114514
            world.say(`${entity.player.name} 帮助了作者,获得了作者的奖励。`)
            break;
        case 1:
            // 如果选择了第二项,即:'现在没空'
            entity.player.directMessage('作者失望地离开了。');
            break;
        default:
            // 注意,使用 switch 分支的时候,不要漏了后面的 break; 
    }

}); 

点赞0


评论