猫史档案馆


帮忙修下代码呗

用户:中國萬歲_青铁迷中國萬歲_青铁迷查看:6 回复:3 评论:6 创建时间:2022-08-05T13:03:41


这是售票+检票系统代码(别人写的)

const elevator = world.querySelector('#闸机的门-2')
elevator.fixed = true
elevator.collides = true
const lo = [38, 27.3, 76.9]
const hi = [36.6, 27, 76.9]
const anissss = elevator.animate([
    { position: lo, duration: 1 },
    { position: lo, duration: 3 },
    { position: hi, duration: 1 },
    { position: hi, duration: 3 },
], {
    duration: 16 * 2,
    iterations: 0,
    direction: Box3AnimationDirection.WRAP,
})
anissss.onReady(() => {
    world.say('闸机成功')
})
anissss.onFinish(() => {
    world.say('')
})

world.querySelectorAll('#闸机-1').forEach((npcs) => {
    npcs.enableInteract = true
    npcs.interactRadius = 2;
    npcs.interactHint = '闸机';
    npcs.onInteract(async ({ entity }) => {
        const result = await entity.player.dialog({
            type: Box3DialogType.SELECT,
            content: `${entity.player.name},请问你要`,
            title: '自动售票机',
            options: ['通过', '没事'],
        })
        if (result.value == '闸机') {
            if (entity.sjjak == 1) {
                anissss.play({
                    duration: 16 * 15,
                    iterations: 1,
                    direction: Box3AnimationDirection.WRAP,
                })
            }else{
                world.say(`${entity.player.name} 你还没买票去买票去`)
            }
        }
    })
})


world.querySelectorAll('#自助售票机-1').forEach((npc) => {
    npc.enableInteract = true; // 允许进行互动
    npc.interactRadius = 6;   // 实体的互动范围
    npc.interactHint = '售票机'; // 互动提示框显示实体的名称
    // npc.interactColor = new Box3RGBColor(1, 0, 1);  // 互动提示的文字颜色

    // // 玩家与实体进行交互时触发
    npc.onInteract(async ({ entity }) => {
        const result = await entity.player.dialog({
            type: Box3DialogType.SELECT,   // 对话框的类型,TEXT是文本框。
            content: `${entity.player.name},请问你要:`,
            title: '自动售票机',
            options: ['买票', '取消'],
        });
        if (result.value == '买票') {
            const result2 = await entity.player.dialog({
                type: Box3DialogType.SELECT,
                content: '是否买票?',
                title: '自动售票机',
                options: ['是', '否']
            })
            if (result2.value == '是') {
                entity.player.dialog({
                    type: Box3DialogType.TEXT,
                    title: '自动售票机',
                    content: '买票成功!',
                })
                entity.sjjak += 1
            }
        }
    })
})

模型都弄好了,名称也好了,为什么按下E键闸机的门还是不开

 


回复

上一页1 页 / 共 1下一页
中國萬歲_青铁迷中國萬歲_青铁迷

地图链接喵ao.cn/e/37a583e34256f66b1d55

点赞0


评论


中國萬歲_青铁迷中國萬歲_青铁迷

ding

点赞0


评论


yee剑走天下yee剑走天下

options: ['通过', '没事']
if (result.value == '闸机')

厉害了()emotion_doge

点赞0


评论