From 511241e03ceaed17017f3ef335f3519e25f03f9d Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Tue, 20 Dec 2022 08:09:35 +1100 Subject: [PATCH] refactor(client/points): ensure coords are a vector --- imports/points/client.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/imports/points/client.lua b/imports/points/client.lua index aaa0f7e..40d529b 100644 --- a/imports/points/client.lua +++ b/imports/points/client.lua @@ -87,6 +87,20 @@ CreateThread(function() end end) +local function toVector(coords) + local _type = type(coords) + + if _type ~= 'vector3' then + if _type == 'table' or _type == 'vector4' then + return vec3(coords[1] or coords.x, coords[2] or coords.y, coords[3] or coords.z) + end + + error(("expected type 'vector3' or 'table' (received %s)"):format(_type)) + end + + return coords +end + lib.points = { ---@return CPoint new = function(...) @@ -108,7 +122,7 @@ lib.points = { } end - + self.coords = toVector(self.coords) self.distance = self.distance or args[2] if args[3] then