for (let Ypos = player.location.y; Ypos < player.location.y + 20; Ypos++) {
let elevatorUp = player.dimension.getBlock({x: player.location.x, y: Ypos , z: player.location.z});
if (elevatorUp.permutation.matches(`minecraft:grass`)) {
player.tryTeleport({x: elevatorUp.location.x + 0.5, y: elevatorUp.location.y + 1, z: elevatorUp.location.z + 0.5})
}
}```
I want the player to teleport to the first block he finds at the height between his position and 20 blocks above the player. Currently, even if he places several blocks, the player teleports to the block that is higher. I want him to teleport to the block that is higher. close in height
#how can I break the loop (for) when the block is found?
1 messages · Page 1 of 1 (latest)
for (let Ypos = player.location.y; Ypos < player.location.y + 20; Ypos++) {
let elevatorUp = player.dimension.getBlock({x: player.location.x, y: Ypos , z: player.location.z});
if (elevatorUp.permutation.matches(`minecraft:grass`)) {
player.tryTeleport({x: elevatorUp.location.x + 0.5, y: elevatorUp.location.y + 1, z: elevatorUp.location.z + 0.5})
break;
}
}```
Like that?