This commit is contained in:
Applevangelist 2022-11-05 14:03:38 +01:00
parent 574fa8abf4
commit b2a351e67d

View File

@ -740,9 +740,11 @@ function UTILS.RemoveMark(MarkID, Delay)
if Delay and Delay>0 then if Delay and Delay>0 then
TIMER:New(UTILS.RemoveMark, MarkID):Start(Delay) TIMER:New(UTILS.RemoveMark, MarkID):Start(Delay)
else else
if MarkID then
trigger.action.removeMark(MarkID) trigger.action.removeMark(MarkID)
end end
end end
end
-- Test if a Vec2 is in a radius of another Vec2 -- Test if a Vec2 is in a radius of another Vec2
@ -1062,9 +1064,13 @@ end
-- @return #number Distance between the vectors. -- @return #number Distance between the vectors.
function UTILS.VecDist2D(a, b) function UTILS.VecDist2D(a, b)
local d = math.huge
if (not a) or (not b) then return d end
local c={x=b.x-a.x, y=b.y-a.y} local c={x=b.x-a.x, y=b.y-a.y}
local d=math.sqrt(c.x*c.x+c.y*c.y) d=math.sqrt(c.x*c.x+c.y*c.y)
return d return d
end end
@ -1076,9 +1082,14 @@ end
-- @return #number Distance between the vectors. -- @return #number Distance between the vectors.
function UTILS.VecDist3D(a, b) function UTILS.VecDist3D(a, b)
local d = math.huge
if (not a) or (not b) then return d end
local c={x=b.x-a.x, y=b.y-a.y, z=b.z-a.z} local c={x=b.x-a.x, y=b.y-a.y, z=b.z-a.z}
local d=math.sqrt(UTILS.VecDot(c, c)) d=math.sqrt(UTILS.VecDot(c, c))
return d return d
end end
@ -2006,6 +2017,22 @@ function UTILS.GenerateLaserCodes()
return jtacGeneratedLaserCodes return jtacGeneratedLaserCodes
end end
--- Ensure the passed object is a table.
-- @param #table Object The object that should be a table.
-- @return #table The object that is a table. Note that if the Object is `#nil` initially, and empty table `{}` is returned.
function UTILS.EnsureTable(Object)
if Object then
if type(Object)~="table" then
Object={Object}
end
else
Object={}
end
return Object
end
--- Function to save an object to a file --- Function to save an object to a file
-- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems. -- @param #string Path The path to use. Use double backslashes \\\\ on Windows filesystems.
-- @param #string Filename The name of the file. Existing file will be overwritten. -- @param #string Filename The name of the file. Existing file will be overwritten.