猫史档案馆


【实用代码】开关门代码and电视换台代码

用户:翎with珝翎with珝查看:0 回复:6 评论:0 创建时间:2023-01-02T15:13:04


1.右键开关门效果

world.querySelectorAll('.门').forEach((e) => {//带有标签“门”的模型
    e.open = 0//初始门的开关情况(0为关,1为开)
    e.onClick(async ({ entity, button, clicker }) => {//如果点击门
        if (button === 'action1') {//点击用的是右键(B)
            if (e.open == 0) {//如果门关的
                e.open = 1//设为开
                e.meshOrientation = meshOrientation = new Box3Quaternion(0, 0.5, 0, 0.5)//5分钱的旋转
                e.position.x -= 0.5//2.5分钱的x移动
                e.position.z += 0.5//2.5分钱的z移动
            } else if (e.open == 1) {//如果门开的
                e.open = 0//设为关
                e.meshOrientation = meshOrientation = new Box3Quaternion(0, 0, 0, 0)//5分钱的旋转,把门掰回来
                e.position.x += 0.5//2.5分钱的x移动,拉回来
                e.position.z -= 0.5//2.5分钱的z移动,扯回来
            }//结尾加上
        }//这个也加上
    })//这俩都要加
})//还有这俩
//根据你门的方向调整meshOrientation的方向

2.电视换台(3个频道的)

world.querySelectorAll('.p1').forEach((b) => {//带有标签“p1”的第二个频道
    b.meshInvisible = true//给他隐藏
})//加上俩结尾

world.querySelectorAll('.p2').forEach((b) => {//带有标签“p2”的第三个频道
    b.meshInvisible = true//也给他隐藏
})//也要加上俩结尾

world.querySelectorAll('.遥控器').forEach((a) => {//带有标签“遥控器”的模型
    a.pd = 0//将初始频道设为0(0为频道1,1为频道2,2为频道3)
    a.onClick(async ({ entity, button, clicker }) => {//点击了模型
        if (button === 'action0') {//按的键是左键(A)
            if (a.pd == 0) {//如果频道是0
                a.pd = 1//频道为1
                world.querySelectorAll('.p0').forEach((b) => {//跟上面一样的
                    b.meshInvisible = true//也跟上面一样的
                })//一样的
                world.querySelectorAll('.p1').forEach((b) => {//不用说了
                    b.meshInvisible = false//你懂的
                })//你还不懂?!
                world.querySelectorAll('.p2').forEach((b) => {//带有标签“p2”的第三个频道*2
                    b.meshInvisible = true//给他隐藏*2
                })//加上俩结尾*2
            } else if (a.pd == 1) {//不用说
                a.pd = 2//这也不用说
                world.querySelectorAll('.p1').forEach((b) => {//跳过了啊
                    b.meshInvisible = true//跳过*2
                })//跳过*3
                world.querySelectorAll('.p0').forEach((b) => {//跳过*4
                    b.meshInvisible = false//跳过*5
                })//跳过*6
                world.querySelectorAll('.p2').forEach((b) => {//跳过*7
                    b.meshInvisible = true//跳过*8
                })//跳过*9
            }else if (a.pd == 2) {//跳过*10
                a.pd = 0//跳过*11
                world.querySelectorAll('.p1').forEach((b) => {//跳过*12
                    b.meshInvisible = true//跳过*13
                })//跳过*14
                world.querySelectorAll('.p0').forEach((b) => {//跳过*15
                    b.meshInvisible = true//跳过*16
                })//跳过*17
                world.querySelectorAll('.p2').forEach((b) => {//跳过*18
                    b.meshInvisible = false//跳过*19
                })//跳过*20
            }//跳过*21
        }//跳过*22
    })//跳过*23
})//跳过*24

代码该怎么用你懂得(


回复

上一页1 页 / 共 1下一页
翎with珝翎with珝

sofa

 

点赞0


评论


屑怪盗屑怪盗

ddd

点赞0


评论


22why22why

ddd()

点赞0


评论


Mini_editMini_edit

终于找到了点击模型的代码(收藏

点赞0


评论


AokenAoken

收藏

点赞0


评论


某只sans喵呀某只sans喵呀

ddd

点赞0


评论