猫史档案馆


[教程贴] 常用跑酷代码!

用户:Star_Ink_sansStar_Ink_sans查看:40 回复:26 评论:40 创建时间:2022-03-15T09:14:09


Hi,这里是Star_Ink_sans~

今天给大家介绍一些跑酷常用代码~

1.跑酷基本功能

//跑酷功能
for (const e of world.querySelectorAll('*')) {//遍历所有实体
    if (e.id.startsWith('存档点')) {
        e.collides = true //开启碰撞
        e.fixed = true //固定实体不被推移
        e.meshScale = e.meshScale.scale(2) //放大零倍
        e.onEntityContact(({ other }) => { 
            if (other.isPlayer) { 
                if (e.position !== other.player.spawnPoint) { 
                    other.player.directMessage('到达新的存档点') 
                    other.player.spawnPoint = e.position // 玩家重生点坐标设置成存档点的坐标
                }
            }
        })
    }
}
world.onPlayerJoin(({ entity }) => {
    entity.onFluidEnter(() => {//当玩家掉到水里
        entity.position.copy(entity.player.spawnPoint)
        entity.position.y += 4
    })
})

注意:1.使用时请把存档点设置成存档点-1,存档点-2,etc的形式

2.我个人不推荐使用方块存档,因为有时会出一些奇奇怪怪的bug,这里不详

 

2.创作者降临!

const FRIEND_PLAYER = ['Star_Ink_sans','A','B','C','.....']

world.onPlayerJoin(({ entity }) => {
    if (!FRIEND_PLAYER.includes(entity.player.name)) return; // 如果玩家名称不在列表里,则跳过后续脚本。
    world.say(`地图创作人员 ${entity.player.name} 降临!`)
    entity.player.canFly = true;
})


注意:列表可以更改~

3.关闭玩家碰撞

world.addCollisionFilter('player','player');

 

4.电梯代码(@吉吉喵)

const elevator = world.querySelector('#电梯板-1') //获取电梯板实体
elevator.fixed = true //不可推移
elevator.collides = true //可碰撞
const pos = elevator.position//电梯板原本的位置

const ani = elevator.animate([
    { position: pos, duration: 1 },
    { position: pos, duration: 10 },
    { position: pos.add({ x: 0, y: 0, z: 15 }), duration: 1 },
    { position: pos.add({ x: 0, y: 0, z: 15 }), duration: 10 },
], {
    duration: 15 * 16 , //播放一个循环共用时15秒(系统默认每秒16帧)
    iterations: Infinity,
    direction: Box3AnimationDirection.WRAP,//让动画实体从终点回到起点
})

注意:自行更改数据~

 

附:速建一层水~

for(let x=0; x<255; x++){
for(let z=0; z<255; z++){
    voxels.setVoxel(x, 8, z, 'water')
}}

注意:1.可以用同样原理建围墙~

2.先放代码区测试,再移到控制台~


回复

上一页1 页 / 共 1下一页
Star_Ink_sansStar_Ink_sans

dddd

点赞0


评论


Star_Ink_sansStar_Ink_sans

自己抢自己的沙发!

点赞0


评论


Star_Ink_sansStar_Ink_sans

没有人看一眼吗。。。

点赞0


评论


yee089yee089

方块的bug多半是在于你忘记entity.isPlayer,没有这个就不能用entity.player了

点赞0


评论


该账号已停用该账号已停用

https://shequ.codemao.cn/community/422769

点赞0


评论


一个STUB用户_14302596一个STUB用户_14302596

可以看看我的教程:https://shequ.cod喵/community/427759

点赞0


评论


坦率的血翼蝠5801坦率的血翼蝠5801

👍

点赞0


评论


坦率的血翼蝠5801坦率的血翼蝠5801

顶顶顶

点赞0


评论


Star_Ink_sansStar_Ink_sans

dddd

点赞0


评论


YLG_個YLG_個

顶顶

点赞0


评论


十殿阎王十殿阎王

话说,跳关代码你会吗

点赞0


评论


豹2a7豹2a7

有用,谢谢

点赞0


评论


灵清帝王吃爆一切厕所灵清帝王吃爆一切厕所

我能说氵吗()

点赞0


评论


灵清帝王吃爆一切厕所灵清帝王吃爆一切厕所

五个月前的我:握喵!喵了老哥!这么厉害的代码让我一脸懵逼

现在的我:????这是啥?()氵贴?氵代码?emotion_doge

无恶意()纯粹开个玩笑emotion_doge

点赞1


评论


Star_Ink_sansStar_Ink_sans

emotion_doge

点赞0


评论


Star_Ink_sansStar_Ink_sans

看 日 期

点赞0


评论


东南西北东南西北

收藏

点赞0


评论


Ada_tjAda_tj

更改列表在哪里更改?(在代码的哪里)

点赞0


评论


raearaea

顶顶顶

点赞0


评论


仙之鹤仙之鹤

一年前()

点赞0


评论


Star_Ink_sansStar_Ink_sans

这是坟贴别挖了()

点赞0


评论


145a145a

nb!!emotion_doge

点赞0


评论


来自远方的panda来自远方的panda

emotion_doge

点赞0


评论


锦衣侠客锦衣侠客

ddd

点赞0


评论


星辰_零柒星辰_零柒

这屑代码还没我萌新跑酷训练营的号,俺家可是有SQL的emotion_doge

点赞0


评论


Aaa求佛yaAaa求佛ya

emotion_编程猫_点赞

点赞0


评论