猫史档案馆


【教程】代码教学——跑酷的代码(如存档,传送等)

用户:老葵老葵查看:28 回复:22 评论:28 创建时间:2020-05-24T09:18:26


你好,我是老葵

这期又是一期不知道多少期的代码教程贴

这期主要讲解跑酷代码

1、存档点

2、起点

3、传送到起点

4、终点奖励

5、掉下回到存档点

6、看我干什么?我是分割线----------------------------------------------------------------------------------

1、存档点

有2种存档点:

第一种:模型存档

//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})

第二种:方块存档(踩S存档)

world.onVoxelContact(({voxel,entity})=>{
const c=voxels.id('S');//也可以是别的方块
    if(voxel===c){
        entity.player.directMessage('存档成功!);
        entity.player.spawnPoint.copy(entity.position);
    }
})

2、起点的提示(加起点标签,开实体关防推移)

world.onPlayerJoin(({entity})=>{
    entity.player.Start=false;//跑酷起点判断,防作弊
    entity.enableDamage=true;//可伤害
})
//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})

3、不想说了太简单,一行就可以了

//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{e.onEntityContact(({entity,other})=>{other.position.set(124, 23, 68);})})//填自己的坐标,标签跟前面一样,怎么做就怎么做

4、一样的简单,也是1行(才怪)

world.querySelectorAll('.终点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.directMessage('你到了终点!获得加速效果!(蹲下加速)以及发光!')
        world.say(other.player.name+'到达了终点!')
        other.player.Start=false;
        other.player.emissive=999;
        other.position.set(73, 10, 77);//这里填出生点坐标
        other.player.spawnPoint.copy(other.position);
    })
})

5、需要配合上面代码

//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})

如果连起来,就是:

//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})
//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})
//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})
//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{e.onEntityContact(({entity,other})=>{other.position.set(124, 23, 68);})})

(这里用了模型存档)

好了,下期出

作弊代码(脚本&控制台,单行代码)


回复

上一页1 页 / 共 1下一页
高贵的木叶龙A35d高贵的木叶龙A35d

沙发

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

地板

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

地下室

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

地心

点赞0


评论


高贵的木叶龙A35d高贵的木叶龙A35d

地核

点赞0


评论


神龙_build神龙_build

Wowo 

点赞0


评论


Lonely_wandererLonely_wanderer

dd

点赞0


评论


凌_墨水凌_墨水

诶,以前也有一个人叫我帮忙修代码,他发的错误代码类型就是存档点代码,注释有一个“//也可以是其他方块”,标注名字也是C,这是巧合呢还是……

点赞0


评论


星河晶梦星河晶梦

一头雾水,这是咋回事,我只是个代码萌新························emotion_编程猫_伤心

center_image

点赞0


评论


两个小八路两个小八路

emotion_编程猫_加油

点赞0


评论


一笑置之_一笑置之_

顶顶

点赞0


评论


老葵老葵

最后的连起来我故意漏了一些代码emotion_doge

点赞1


评论


兮珤兮珤

点赞0


评论


文件传输助脚文件传输助脚

center_image

点赞0


评论


害羞的独角蛛907害羞的独角蛛907

收藏。

点赞0


评论


build_一只建筑师吖build_一只建筑师吖

矫正后代码:

1、存档点

2、起点

3、传送到起点

4、终点奖励

5、掉下回到存档点

6、看我干什么?我是分割线----------------------------------------------------------------------------------

1、存档点

有2种存档点:

第一种:模型存档

//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})

第二种:方块存档(踩S存档)

world.onVoxelContact(({voxel,entity})=>{
const c=voxels.id('S');//也可以是别的方块
    if(voxel===c){
        entity.player.directMessage('存档成功!');
        entity.player.spawnPoint.copy(entity.position);
    }
})

2、起点的提示(加起点标签,开实体关防推移)

world.onPlayerJoin(({entity})=>{
    entity.player.Start=false;//跑酷起点判断,防作弊
    entity.enableDamage=true;//可伤害
})
//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})

3、详细一点了

//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.position.set();
})})

4、一样的简单,也是1行(才怪)

world.querySelectorAll('.终点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        other.player.directMessage('你到了终点!获得加速效果!(蹲下加速)以及发光!')
        world.say(other.player.name+'到达了终点!')
        other.player.Start=false;
        other.player.emissive=999;
        other.position.set(73, 10, 77);//这里填出生点坐标
        other.player.spawnPoint.copy(other.position);
    })
})

5、需要配合上面代码

//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})

如果连起来,就是:

//跑酷起点
world.querySelectorAll('.起点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==false){
            world.say(other.player.name+'出发了!');
            other.player.Start=true;
            other.player.spawnPoint.copy(other.position);
        }
    })
})
//存档点:可放置多个,需要加存档点标签,同时存档点需要开实体化,可推移要关掉
world.querySelectorAll('.存档点').forEach((e)=>{
    e.onEntityContact(({entity,other})=>{
        if(other.player.Start==true){
            other.player.spawnPoint.copy(other.position);
            other.player.directMessage('存档成功!')
        }
    })
})
//如果玩家跑酷中,一到地上就凉凉
world.onTick(({entity})=>{
    world.querySelectorAll('player').forEach((e)=>{
        if(e.player.Start==true){
            if(e.position.y<=15){
                e.hurt(999)
            }
        }
    })
})
//跑酷快速传送门
world.querySelectorAll('.跑酷传送门').forEach((e)=>{e.onEntityContact(({entity,other})=>{other.position.set(124, 23, 68);})})

PS:红字部分是矫正的部分

点赞0


评论


666真是6666真是6

555,为什么开了 实体化 又加了 标签 却没用?

点赞1


评论


七式草莓七式草莓

求上门安装(https://box3create.codemao.cn/games/3d091f029848e68fe3f4?p=34H4E喵pPAUlT1%2BoNZs0ywfSojG7zPq0g%2FwRezYA6CA6Dq3je%2BLgVndWVzdA%3D%3D

点赞0


评论


帅气的剑杰帅气的剑杰

额,我掉下去就喵了............复不了活了................

点赞0


评论


面具狐狸云绾兮面具狐狸云绾兮

老葵怎么也来BEST了

点赞0


评论


MiHaYoMiHaYo

为啥我不行

点赞0


评论


是小芊a是小芊a

谢谢

点赞0


评论