猫史档案馆


解答“@天才喵@” 我做了一个跑酷地图,但不知道怎么弄碰到岩浆就喵,谁能帮帮我,呜呜

用户:0ttB0ttB查看:5 回复:6 评论:5 创建时间:2021-06-05T19:53:03


岩浆方块为lava01

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true
    entity.onVoxelContact(({ voxel, entity }) => {
        if (voxel === 465) {
            entity.hurt(100)
        }
    })
} 

岩浆方块为lava02

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true
    entity.onVoxelContact(({ voxel, entity }) => {
        if (voxel === 467) {
            entity.hurt(100)
        }
    })
})

复活

world.onDie(({ entity }) => {
    entity.hp = entity.maxHp
})


回复

上一页1 页 / 共 1下一页
0ttB0ttB

改一改,标题那个“喵”应该成“猫”

点赞0


评论


async_functionasync_function

把if(voxel==465)改成if(voxel==voxels.id('lava01'))

if(voxel==467)改成if(voxel==voxels.id('lava02'))试试

点赞1


评论


七式草莓七式草莓

解决代码(都有了):

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true
})

world.onVoxelContact(({ voxel, entity }) => {
    if (voxel == voxels.id('lava01')) {
        entity.hurt(entity.maxHp)
    }
    if (voxel == voxels.id('lava02')) {
        entity.hurt(entity.maxHp)
    }
})

world.onDie(({ entity }) => {
    entity.hp = entity.maxHp
    entity.forceRespawn()
})

问题信息:

1.第一个末尾缺了“)”

2.如果玩家最大生命值超过了100就不能被击杀

3.方块id可能错了

4.你喵了就复活,没有音效,没有提示,没有强制重生,也没有等待,当然谁都不知道了

点赞1


评论


爱探险的天才猫爱探险的天才猫

emotion_编程猫_搓头

点赞0


评论


AlbertAJLKAlbertAJLK

world.onPlayerJoin(({ entity }) => {
    entity.enableDamage = true
})

world.onVoxelContact(({ voxel, entity }) => {
    if (voxel == voxels.id('lava01')) {
        entity.hurt(entity.maxHp)
    }
    if (voxel == voxels.id('lava02')) {
        entity.hurt(entity.maxHp)
    }
})
world.onDie(async ({ entity }) => {
    await sleep(3000)
    entity.hp = entity.maxHp //复活
    })

点赞0


评论


VernierVernier

这个应该更好:

for (const e of world.querySelectorAll('*')) {
    if (e.id.startsWith('存档点')) {
        e.onEntityContact(({ other }) => {
            if (other.isPlayer) {
                other.player.directMessage('已存档')
                other.player.spawnPoint = e.position
            }
        })
    }
}
world.onPlayerJoin(({ entity }) => {
    world.onVoxelContact(({ voxel, entity }) => {
        if (voxel == voxels.id('lava01')) {
            entity.position.copy(entity.player.spawnPoint)
	    entity.position.y += 4
	})
    })
}) 

点赞0


评论