whitespace, some documentation added

This commit is contained in:
MrNewb committed 2025-03-24 18:06:52 -04:00
1 parent a3901481d4
commit cad3604e4d
3 files changed
+28 -7

No files matched your search

-3
View File
@@ -1,4 +1,3 @@
function CreateParticleFX(dict, ptfx, pos, rot, scale, color, looped, loopLength) function CreateParticleFX(dict, ptfx, pos, rot, scale, color, looped, loopLength)
CreateThread(function() CreateThread(function()
local failed = 5 local failed = 5
@@ -45,8 +44,6 @@ function CreateParticleFXOnEntityBone(dict, ptfx, entity, bone, offset, rot, sc
return bleh return bleh
end end
function PlayParticleFX(dict, name, looped, x, y, z, rotX, rotY, rotZ, scale) function PlayParticleFX(dict, name, looped, x, y, z, rotX, rotY, rotZ, scale)
RequestNamedPtfxAsset(dict) RequestNamedPtfxAsset(dict)
while not HasNamedPtfxAssetLoaded(dict) do while not HasNamedPtfxAssetLoaded(dict) do
-2
View File
@@ -191,5 +191,3 @@ function PlaceableObject.Create(data, model, onConfirm, onUpdate, onCancel, sett
end end
return PlaceableObject return PlaceableObject
+28 -2
View File
@@ -11,12 +11,14 @@ local CELL_BUFFER = 1 -- Number of adjacent cells to check
-- Consider adding these optimizations -- Consider adding these optimizations
local ADAPTIVE_WAIT = true -- Adjust wait time based on player speed local ADAPTIVE_WAIT = true -- Adjust wait time based on player speed
---This is an internal function, do not call this externally
function Point.GetCellKey(coords) function Point.GetCellKey(coords)
local cellX = math.floor(coords.x / GRID_SIZE) local cellX = math.floor(coords.x / GRID_SIZE)
local cellY = math.floor(coords.y / GRID_SIZE) local cellY = math.floor(coords.y / GRID_SIZE)
return cellX .. ":" .. cellY return cellX .. ":" .. cellY
end end
---This is an internal function, do not call this externally
function Point.RegisterInGrid(point) function Point.RegisterInGrid(point)
local cellKey = Point.GetCellKey(point.coords) local cellKey = Point.GetCellKey(point.coords)
@@ -34,6 +36,7 @@ function Point.RegisterInGrid(point)
point.cellKey = cellKey point.cellKey = cellKey
end end
---This is an internal function, do not call this externally
function Point.UpdateInGrid(point, oldCellKey) function Point.UpdateInGrid(point, oldCellKey)
-- Remove from old cell if cell key changed -- Remove from old cell if cell key changed
if oldCellKey and oldCellKey ~= point.cellKey then if oldCellKey and oldCellKey ~= point.cellKey then
@@ -52,6 +55,9 @@ function Point.UpdateInGrid(point, oldCellKey)
end end
end end
---Gets nearby cells based on the coords
---@param coords table
---@return table
function Point.GetNearbyCells(coords) function Point.GetNearbyCells(coords)
local cellX = math.floor(coords.x / GRID_SIZE) local cellX = math.floor(coords.x / GRID_SIZE)
local cellY = math.floor(coords.y / GRID_SIZE) local cellY = math.floor(coords.y / GRID_SIZE)
@@ -70,6 +76,10 @@ function Point.GetNearbyCells(coords)
return nearbyCells return nearbyCells
end end
---Returns all points in the same cell as the given point
---This will require you to pass the point object
---@param point table
---@return table
function Point.CheckPointsInSameCell(point) function Point.CheckPointsInSameCell(point)
local cellKey = point.cellKey local cellKey = point.cellKey
if not GridCells[cellKey] then return {} end if not GridCells[cellKey] then return {} end
@@ -87,6 +97,7 @@ function Point.CheckPointsInSameCell(point)
return nearbyPoints return nearbyPoints
end end
---Internal function that starts the loop. Do not call this function directly.
function Point.StartLoop() function Point.StartLoop()
if LoopStarted then return false end if LoopStarted then return false end
LoopStarted = true LoopStarted = true
@@ -152,8 +163,16 @@ function Point.StartLoop()
return true return true
end end
---Create a point based on a vector or entityID
---@param id string
---@param target number || vector3
---@param distance number
---@param _onEnter function
---@param _onExit function
---@param _onNearby function
---@param data self
---@return table
function Point.Register(id, target, distance, _onEnter, _onExit, _onNearby, data) function Point.Register(id, target, distance, _onEnter, _onExit, _onNearby, data)
local isEntity = type(target) == "number" local isEntity = type(target) == "number"
local coords = isEntity and GetEntityCoords(target) or target local coords = isEntity and GetEntityCoords(target) or target
@@ -174,6 +193,8 @@ function Point.Register(id, target, distance, _onEnter, _onExit, _onNearby, data
return self return self
end end
---Remove an exsisting point by its id
---@param id string
function Point.Remove(id) function Point.Remove(id)
local point = ActivePoints[id] local point = ActivePoints[id]
if point then if point then
@@ -191,15 +212,21 @@ function Point.Remove(id)
end end
end end
---Returnes a point by its id
---@param id string
---@return table
function Point.Get(id) function Point.Get(id)
return ActivePoints[id] return ActivePoints[id]
end end
---Returns all points
---@return table
function Point.GetAll() function Point.GetAll()
return ActivePoints return ActivePoints
end end
-- Usage example for checking nearby points -- Usage example for checking nearby points
-- This is fucking hot. +20 points for crowley
--[[ --[[
Point.Register("point1", vector3(100, 100, 30), 5.0, Point.Register("point1", vector3(100, 100, 30), 5.0,
function(point) function(point)
@@ -218,4 +245,3 @@ Point.Register("point1", vector3(100, 100, 30), 5.0,
--]] --]]
return Point return Point