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

View File

@ -740,7 +740,9 @@ function UTILS.RemoveMark(MarkID, Delay)
if Delay and Delay>0 then
TIMER:New(UTILS.RemoveMark, MarkID):Start(Delay)
else
trigger.action.removeMark(MarkID)
if MarkID then
trigger.action.removeMark(MarkID)
end
end
end
@ -1062,9 +1064,13 @@ end
-- @return #number Distance between the vectors.
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 d=math.sqrt(c.x*c.x+c.y*c.y)
d=math.sqrt(c.x*c.x+c.y*c.y)
return d
end
@ -1076,9 +1082,14 @@ end
-- @return #number Distance between the vectors.
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 d=math.sqrt(UTILS.VecDot(c, c))
d=math.sqrt(UTILS.VecDot(c, c))
return d
end
@ -2006,6 +2017,22 @@ function UTILS.GenerateLaserCodes()
return jtacGeneratedLaserCodes
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
-- @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.