Location
Syntax¶
Locations are created using the loc constructor. Like all constructors in Terracotta, the values passed into the constructor are Expressions and can take full advantage of their features.
pitch and yaw are optional and will default to 0 if omitted.
Coordinate Access¶
The coordinates of locations can be accessed with a dot (.) followed by x, y, z, pitch, or yaw. In addition to getting the value of the coordinate, the coordinate can also be assigned to.
if (default.location.y > 255) {
line plr_loc = default.location;
plr_loc.y = 255;
default.teleport(plr_loc);
default.sendMessage("Stay in bounds!");
}
Floating-Point Behavior¶
Locations share the same floating-point behavior as Vectors.
When locations along vectors using the + or - operators, full precision is maintained.
Operations¶
+ (Addition)¶
loc + vec: loc¶
This operator is one-way! You can do loc + vec, but you cannot do vec + loc.
Adds the XYZ coordinates of the right Vector to the XYZ coordinates of the left Location, leaving Pitch and Yaw untouched.
loc + txt: txt¶
Stringifies the Location then adds it onto the Styled Text.
loc(10, 50, 10) + s" is the spawn point!" = s"[10, 50, 10] is the spawn point!"
s"The spawn point is: " + loc(10, 50, 10) = s"The spawn point is: [10, 50, 10]"
- (Subtraction)¶
loc - vec: loc¶
This operator is one-way! You can do loc - vec, but you cannot do vec - loc.
Subtracts the XYZ coordinates of the right Vector from the XYZ coordinates of the left Location, leaving Pitch and Yaw untouched.