points verification
hopefully fix issue with teleportation
This commit is contained in:
1 parent
bfbf3e8f61
commit
2501612788
1 file changed
+16
-1
+16
-1
@@ -97,6 +97,7 @@ function Point.CheckPointsInSameCell(point)
|
|||||||
return nearbyPoints
|
return nearbyPoints
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local insidePoints = {}
|
||||||
---Internal function that starts the loop. Do not call this function directly.
|
---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
|
||||||
@@ -140,11 +141,23 @@ function Point.StartLoop()
|
|||||||
print("Entered point: ", point.distance)
|
print("Entered point: ", point.distance)
|
||||||
point.inside = true
|
point.inside = true
|
||||||
point.onEnter(point)
|
point.onEnter(point)
|
||||||
|
insidePoints[point.id] = point
|
||||||
end
|
end
|
||||||
elseif point.inside then
|
elseif point.inside then
|
||||||
print("Exited point: ", point.id)
|
print("Exited point: ", point.id)
|
||||||
point.inside = false
|
point.inside = false
|
||||||
point.onExit(point)
|
point.onExit(point)
|
||||||
|
insidePoints[point.id] = nil
|
||||||
|
end
|
||||||
|
for id, insidepoint in pairs(insidePoints) do
|
||||||
|
local pos = insidepoint.coords and vector3(insidepoint.coords.x, insidepoint.coords.y, insidepoint.coords.z) or vector3(0, 0, 0)
|
||||||
|
local dist = #(playerCoords - pos)
|
||||||
|
if dist > insidepoint.distance then
|
||||||
|
print("Exited point: ", insidepoint.id)
|
||||||
|
insidepoint.inside = false
|
||||||
|
insidepoint.onExit(insidepoint)
|
||||||
|
insidePoints[insidepoint.id] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if point.onNearby then
|
if point.onNearby then
|
||||||
point.onNearby(GridCells[cellKey]?.points, waitTime)
|
point.onNearby(GridCells[cellKey]?.points, waitTime)
|
||||||
@@ -229,7 +242,9 @@ function Point.GetAll()
|
|||||||
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)
|
||||||
|
|||||||
Reference in new issue
Block a user