From 62a0a2fe0b2e0184ff18bb2bc862a770c8bab06d Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Thu, 20 Apr 2023 15:55:06 +1000 Subject: [PATCH] feat(client/points): add new getter functions --- imports/points/client.lua | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/imports/points/client.lua b/imports/points/client.lua index 06384a0..9395c62 100644 --- a/imports/points/client.lua +++ b/imports/points/client.lua @@ -1,18 +1,23 @@ ----@class CPoint ----@field id number +---@class PointProperties ---@field coords vector3 ---@field distance number ----@field currentDistance number ----@field isClosest? boolean ----@field remove fun() ---@field onEnter? fun(self: CPoint) ---@field onExit? fun(self: CPoint) ---@field nearby? fun(self: CPoint) ---@field [string] any +---@class CPoint : PointProperties +---@field id number +---@field currentDistance number +---@field isClosest? boolean +---@field remove fun() + +---@type table local points = {} +---@type CPoint[] local nearbyPoints = {} local nearbyCount = 0 +---@type CPoint? local closestPoint local tick @@ -107,6 +112,8 @@ end lib.points = { ---@return CPoint + ---@overload fun(data: PointProperties): CPoint + ---@overload fun(coords: vector3, distance: number, data?: PointProperties): CPoint new = function(...) local args = {...} local id = #points + 1 @@ -140,10 +147,15 @@ lib.points = { return self end, - ---@return CPoint - closest = function() - return closestPoint - end + getAllPoints = function() return points end, + + getNearbyPoints = function() return nearbyPoints end, + + ---@return CPoint? + getClosestPoint = function() return closestPoint end, } +---@deprecated +lib.points.closest = lib.points.getClosestPoint + return lib.points