refactor(client/points): ensure coords are a vector

This commit is contained in:
Linden
2022-12-20 08:09:35 +11:00
parent 08a725105b
commit 511241e03c

View File

@@ -87,6 +87,20 @@ CreateThread(function()
end end
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 = { lib.points = {
---@return CPoint ---@return CPoint
new = function(...) new = function(...)
@@ -108,7 +122,7 @@ lib.points = {
} }
end end
self.coords = toVector(self.coords)
self.distance = self.distance or args[2] self.distance = self.distance or args[2]
if args[3] then if args[3] then