From 7c889962109aa4f5dafd43679767c517293ec7a6 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Sun, 10 Aug 2025 17:03:52 +0200 Subject: [PATCH] Use vector type in core.parse_coordinates() --- builtin/common/misc_helpers.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/common/misc_helpers.lua b/builtin/common/misc_helpers.lua index 94cd6276a..c33465e21 100644 --- a/builtin/common/misc_helpers.lua +++ b/builtin/common/misc_helpers.lua @@ -853,22 +853,22 @@ Intended to be used in chat command parameter parsing. Parameters: * x, y, z: Parsed x, y, and z coordinates as strings -* relative_to: Position to which to compare the position +* relative_to: Optional position vector as reference point Syntax of x, y and z: -* "": return as number -* "~": return + player position on this axis -* "~": return player position on this axis +* "": use as number +* "~": use + reference point on this axis +* "~": use reference point on this axis -Returns: a vector or nil for invalid input or if player does not exist +Returns: a vector or nil for invalid input ]] function core.parse_coordinates(x, y, z, relative_to) if not relative_to then x, y, z = tonumber(x), tonumber(y), tonumber(z) - return x and y and z and { x = x, y = y, z = z } + return x and y and z and vector.new(x, y, z) end local rx = core.parse_relative_number(x, relative_to.x) local ry = core.parse_relative_number(y, relative_to.y) local rz = core.parse_relative_number(z, relative_to.z) - return rx and ry and rz and { x = rx, y = ry, z = rz } + return rx and ry and rz and vector.new(rx, ry, rz) end