用户:
卿宸cq查看:1 回复:3 评论:1 创建时间:2022-04-11T19:03:45
有人能分享一些作品代码吗
飞跃的流星丨冲四千粉跑酷训练场v3.7代码全公开(反正浏览只有1k)
/* 受到伤害时,向玩家发送私信,提示战斗信息 */
world.onTakeDamage(({ entity, attacker, damage}) => {
if (!entity.isPlayer) return;
const attackerName = attacker.isPlayer ? attacker.player.name : attacker.id;
entity.player.directMessage(`[剩余HP: ${entity.hp}]: 你受到了 ${damage} 点来自"岩浆"的伤害`);
});
world.onVoxelContact(({ entity, voxel, x, y, z }) => {
if (voxel === voxels.id('ice')) {
voxels.setVoxel(x, y, z, '')
}
})
world.onPlayerJoin(({ entity }) => {
entity.onVoxelContact(async({ entity , voxel}) => {
if(voxel == voxels.id('lava02')) {
entity.enableDamage = true;
entity.hurt(10);
sleep(2)
}
})
})
world.onVoxelContact(({ entity, voxel, x, y, z }) => {
if (voxel === voxels.id('carpet_08')) {
entity.hp = entity.maxHp
}
})
world.onDie(async({ entity }) => {
if (!entity.isPlayer) return;
for (let t = 1; t <= 6; t++) {
entity.player.directMessage(`你还有 ${String(6 - t)} 秒后复活`);
await sleep(1000);
}
entity.player.forceRespawn();
});
for (const e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('存档点')) {//如果当前实体名左边部分刚好是"存档点", 比如 存档点-1 存档点-2...
e.collides = true //开启碰撞
e.fixed = true //固定实体不被推移
e.meshScale = e.meshScale.scale(1) //放大2倍
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
other.player.directMessage('到达新的重生点') // 给玩家发消息
other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
}
}
})
}
}
for (const e of world.querySelectorAll('*')) {//遍历所有实体
if (e.id.startsWith('终点')) {//如果当前实体名左边部分刚好是"终点", 比如 终点-1 终点-2...
e.collides = true //开启碰撞
e.fixed = true //固定实体不被推移
// e.meshScale = e.meshScale.scale(2) //放大2倍
e.onEntityContact(({ other }) => { //每当存档点碰到另一个实体
if (other.isPlayer) { //另一个实体是玩家
if (e.position !== other.player.spawnPoint) { // 检测当前存档点是否玩家重生点, 避免反复在同一个存档点做多余的保存
other.player.directMessage('到达终点!') // 给玩家发消息
other.player.canFly = true
world.say(`恭喜${other.player.name}到达了跑酷终点并获得了飞行奖励`)
other.player.spawnPoint = e.position // 喵家重生点坐标设置成存档点的坐标
}
}
})
}
}
//world.onPlayerJoin(({ entity }) => {
//const dialog = entity.player.dialog({
//type: Box3DialogType.TEXT,
//title: "飞跃的流星",
//titleTextColor: new Box3RGBAColor(0, 0, 0, 1),
//titleBackgroundColor: new Box3RGBAColor(0.968, 0.702, 0.392, 1),
//content: `欢迎你来到这个跑酷!到达终点会有飞行奖励哦!加油!`,
//contentTextColor: new Box3RGBAColor(0, 0, 0, 1),
//contentBackgroundColor: new Box3RGBAColor(1, 1, 1, 1), //颜色
//lookEye: entity.position.add(entity.player.facingDirection.scale(5)),
//lookTarget: entity,
//});
//});//这个是显示对话框
//world.onPress(async({entity,button})=>{
//if(button == Box3ButtonType.ACTION0){
//const say = await entity.player.dialog({
// type:'input',
// title:'请输入要说的话:',
// content:'',
// confirmText:'发送',
//})
//if(say == null||say.length >= 20 ){return}
// world.say(entity.player.name+':'+say)
//}
//})
world.onPlayerJoin(({ entity }) => {
entity.onFluidEnter(() => {
entity.position.copy(entity.player.spawnPoint)
entity.position.y += 4
})
})
world.querySelectorAll('.invisible').forEach((e)=>{e.meshInvisible=true})
const TEST_PLAYER = ['飞跃的流星']
world.onPlayerJoin(({ entity }) => {
if (!TEST_PLAYER.includes(entity.player.name)) return; // 如果玩家名称不在列表里,则跳过后续脚本。
world.say(`创作者--${entity.player.name} 出现了!`);
})
//地图和模型要自己建
点赞0
评论