pos Local
Creates a new local position: ^right/^left, ^up/^down, ^forward/^backward.
posLocal(0, 0, 0)
A local position is a position in the direction where the the player is looking. Unlike a player position, a local position doesn’t relate to the coordinate axes of the world. For example, if the player is standing on the ground and looking downward, the forward
coordinate specifies a place in the ground. Likewise, if the player is looking at the horizon toward the Northwest, the forward
coordinate refers to a position directly ahead of the players’s view and not along any relative axis in the North or West direction.
So, when the player is looking at the horizon in the Northwest direction, this code will place a light blue concrete
block between a relative North and West axis:
blocks.place(LIGHT_BLUE_CONCRETE, posLocal(0, 0, 7))
Read about how different types of positions work in the positions reference.
Parameters
- x: the right (+x) or left (-x) distance from the player’s view, in blocks.
- y: the up (+y) or down (-y) distance from the player’s view, in blocks. The
0
position is at the players feet, the1
position is at the player’s eye level. - z: the forward (+z) or backward (-z) distance from the player’s view, in blocks.
Example
Make two chat commands. One command creates a two-axis marker in the ground using relative coordinates. The other command will place a block of diamond
at a distance of 5
blocks in front of the player. Have the player face toward the Northwest direction on the coordinate axes of polished andesite
and place a diamond
block.
player.onChat("twoaxis", function () {
for (let index = 0; index <= 16; index++) {
blocks.place(POLISHED_ANDESITE, pos(0, -1, index))
blocks.place(POLISHED_ANDESITE, pos(0, -1, -1 - index))
blocks.place(POLISHED_ANDESITE, pos(index , -1, 0))
blocks.place(POLISHED_ANDESITE, pos(-1 - index , -1, 0))
}
blocks.print(
"N",
YELLOW_CONCRETE,
pos(0, 3, -33),
EAST
)
blocks.print(
"W",
YELLOW_CONCRETE,
pos(-33, 3, 0),
NORTH
)
})
player.onChat("placelocal", function () {
blocks.place(DIAMOND_BLOCK, posLocal(0, 0, 5))
})