猫史档案馆


解决报错以及求助

用户:清瞑月风GUI清瞑月风GUI查看:1 回复:4 评论:1 创建时间:2021-09-25T20:03:05


报错。

console.clear()
function textDialog(entity, content, title) {
    return entity.player.dialog({ //弹出对话框
        type: Box3DialogType.TEXT, //对话框类型为纯文本
        content, //文本内容
        title, //对话框左上角标题内容
    })
}

world.onPlayerJoin(({ entity }) => { //玩家进入游戏时在这里初始化玩家的资产
    entity.player.onPress(({ button }) => { //每当有按钮被按下
        if (button == Box3ButtonType.ACTION1) { //如果按钮是右键
            textDialog(entity, `你身上有:\n道具: [${entity.itemList}]\n装备了:[${entity.wuqi}]`)
        }
        else if (button == Box3ButtonType.CROUCH) { //如果按钮是c键          
            const eaten = entity.wuqi = entity.itemList.pop() //口袋列表最右边的一个物品拿出来
                 if (eaten) {
                     entity.player.directMessage(`${entity.player.name}装备了"${eaten}"`)
                    if (entity.wuqi==='弓'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/[比武大赛]弓.vb',
                          orientation: new Box3Quaternion(0,1,0.5,0).rotateY(Math.PI),
                          offset: new Box3Vector3(-0.05,-0.15,0),
                         scale: Box3Vector3 = new Box3Vector3(0.3, 0.3, 0.3),
                        });
                    }
                    else if (entity.wuqi==='破灭戟'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/[比武大赛]破灭戟.vb',
                          orientation: new Box3Quaternion(0,1,0.5,0).rotateY(Math.PI),
                          offset: new Box3Vector3(-0.05,-0.15,0),
                         scale: Box3Vector3 = new Box3Vector3(0.3, 0.3, 0.3),
                        });
                    }
                    else if (entity.wuqi==='超级钻石剑'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/超级钻石剑.vb',
                          orientation: new Box3Quaternion(1,1,1.5,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(-0.05,-0.15,0),
                         scale: Box3Vector3 = new Box3Vector3(1, 1, 1),
                        });
                    }
                    else if (entity.wuqi==='大喵'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/大喵.vb',
                          orientation: new Box3Quaternion(1,0,0,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(-0.05,-0.15,0),
                         scale: Box3Vector3 = new Box3Vector3(0.3, 0.3, 0.3),
                        });
                    }
                    else if (entity.wuqi==='刀'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/刀.vb',
                          orientation: new Box3Quaternion(1,0,0,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(-0.05,-0.3,0),
                         scale: Box3Vector3 = new Box3Vector3(0.3, 0.3, 0.3),
                        });
                    }
                    else if (entity.wuqi==='喵喵'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/喵喵.vb',
                          orientation: new Box3Quaternion(0,-1,0,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(0,-0.15,1),
                         scale: Box3Vector3 = new Box3Vector3(0.4, 0.4, 0.4),
                        });
                    }
                    else if (entity.wuqi==='光剑'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/光剑(简易版).vb',
                          orientation: new Box3Quaternion(-1,0,0,1).rotateY(Math.PI),
                          offset: new Box3Vector3(0,-0.15,1),
                         scale: Box3Vector3 = new Box3Vector3(0.4, 0.4, 0.4),
                        });
                    }
                    else if (entity.wuqi==='金剑'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/金剑.vb',
                          orientation: new Box3Quaternion(1,1,1.5,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(0,-0.15,1),
                         scale: Box3Vector3 = new Box3Vector3(0.4, 0.4, 0.4),
                        });
                    }
                    else if (entity.wuqi==='生态剑'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/生态剑.vb',
                          orientation: new Box3Quaternion(1,1,1.5,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(0,-0.15,1),
                         scale: Box3Vector3 = new Box3Vector3(0.4, 0.4, 0.4),
                        });
                    }
                    else if (entity.wuqi==='焰之弓'){
                      entity.player.addWearable({
                         bodyPart: Box3BodyPart.RIGHT_HAND,
                          mesh: 'mesh/焰之弓.vb',
                          orientation: new Box3Quaternion(0,-1,0,0).rotateY(-Math.PI),
                          offset: new Box3Vector3(0,-0.15,1),
                         scale: Box3Vector3 = new Box3Vector3(0.4, 0.4, 0.4),
                        });
                    }
                                                    
                }
        }
    })
})


for (const npc of world.querySelectorAll('.NPC')) {
    npc.enableInteract = true //允许当前npc实体触发交互
    npc.interactRadius = 4.5 //交互范围
    npc.interactHint = npc.id //交互提示文本显示实体名字
    npc.interactColor.set(0, 1, 0) //交互提示文本颜色为绿色

    if (npc.id == '武器库') { //如果实体名是'小卖部老板'
        npc.onInteract(async ({ entity }) => { //当玩家对这个npc按E触发交互, npc问你想买哪些商品
            const goodsList = ['弓', '破灭戟', '超级钻石剑','大喵','刀','喵喵','光剑','金剑','生态剑','焰之弓'] //货品列表
            const selection = await entity.player.dialog({
                type: Box3DialogType.SELECT, //对话框类型为选择框
                content: `选择武器:`,
                title: npc.id, //对话框左上角显示NPC名字
                options: ['弓', '破灭戟', '超级钻石剑','大喵','刀','喵喵','光剑','金剑','生态剑','焰之弓'], //选项
            })
            if (selection) { //如果玩家没有点击'x'关闭对话框
                const goods = goodsList[selection.index] //被选中的货物
                    entity.itemList.push(goods) //货物装进玩家口袋列表最右边
                    textDialog(entity, `"${goods}"入手`)
                
            }    
        })
    }
}
world.onPlayerJoin(({ entity }) => {
    entity.player.forceRespawn() //传送到自己队伍的出生点
    entity.enableDamage = true //允许玩家受伤
    entity.score = 0 //玩家初始得分为0
    entity.wuqi = [] //player has no 喵...
    entity.itemList = [] //口袋里的货品
})

结果过了这一个流程。就报错了。

与武器库交互。得到弓.下蹲,手上拿着弓。继续与武器库交互。得到大喵。下蹲。报错。

报错结果如下:

TypeError:Box3Vector3 is not a constructor
at eval(
index.js:51:35
)

还有一个不显示出来,却点击右键查看显示undefined。

开始点击。下蹲。然后点击右键。装备显示的是undefined。

求助。

一,怎样做出发光的模型?

二,怎样向地图:“深海对决“,”赤壁忍者”一样能在几秒内恢复地图?

期待大家的回复,我是个萌新,啥也不懂。。。


回复

上一页1 页 / 共 1下一页
清瞑月风GUI清瞑月风GUI

如果你们实在懒得打代码,可以进这个链接。 https://box3.cod喵/e/d877659efc0257bbb521?p=NdoKsnADWfFFQbPhp2EGWFZDrJcqWMs5u7GJq1aXM1A8Gn%2FA%2FCLxXku6PnoIHmiqXplJnop6PlhrPogIU%3D

点赞0


评论


星星上的雪花星星上的雪花

2.(仅学习及使用,勿抄袭勿转载)

//128普通地图

//备份
world.save=[];
for(x=0;x<128;x++){
for(y=0;y<128;y++){
for(z=0;z<128;z++){
    if(voxels.getVoxelId(x,y,z)!=0){
        world.save.push([x,y,z,voxels.getVoxelId(x,y,z)]);
    };
}}};

//还原
for(e of world.save){
    voxels.setVoxelId(e[0],e[1],e[2],e[3]);
};

点赞0


评论


清瞑月风GUI清瞑月风GUI

https://box3.codemao.cn/e/2c120e71ee30d6e305f1?p=5BevfQX%2BvQDNy%2BSpY1rvVlMB8xHSOzaYiRprMVjCUOA5Pc2QLFLwt喵250cmlidXRvcg%3D%3D 喵=j,b

点赞0


评论


Forzen_SevenForzen_Seven

解决方案:

按住ctrl+h

右上角是不是有两个输入框?

上面的那一个输入“Box3Vector3 = ”

下面的那个什么也不写

然后那个面板的右下角有两个按钮

按下右边的那个

en问题解决

点赞0


评论