From 080cadb8e0197f3a9dfef689a8ba93b41be97b97 Mon Sep 17 00:00:00 2001 From: Grey-Echo Date: Mon, 27 Mar 2017 12:03:51 +0200 Subject: [PATCH] Add a check for the Radius parameter in POSITIONABLE:GetRandomVec3(Radius) --- Moose Development/Moose/Wrapper/Group.lua | 6 ++-- .../Moose/Wrapper/Positionable.lua | 22 +++++++++----- .../l10n/DEFAULT/Moose.lua | 30 ++++++++++++------- Moose Mission Setup/Moose.lua | 30 ++++++++++++------- 4 files changed, 59 insertions(+), 29 deletions(-) diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index e2c5f9b45..d6cfb5cc6 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -474,10 +474,12 @@ end -- @param #GROUP self -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The random 3D point vector around the first UNIT of the GROUP. --- @return #nil The GROUP is invalid or empty +-- @return #nil The GROUP is invalid or empty +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function GROUP:GetRandomVec3(Radius) self:F2(self.GroupName) - + local FirstUnit = self:GetUnit(1) if FirstUnit then diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index e20c0c7cc..e6bd95cd3 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -138,6 +138,8 @@ end -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The 3D point vector of the POSITIONABLE. -- @return #nil The POSITIONABLE is not existing or alive. +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function POSITIONABLE:GetRandomVec3( Radius ) self:F2( self.PositionableName ) @@ -145,14 +147,20 @@ function POSITIONABLE:GetRandomVec3( Radius ) if DCSPositionable then local PositionablePointVec3 = DCSPositionable:getPosition().p - local PositionableRandomVec3 = {} - local angle = math.random() * math.pi*2; - PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; - PositionableRandomVec3.y = PositionablePointVec3.y - PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; - self:T3( PositionableRandomVec3 ) - return PositionableRandomVec3 + if Radius then + local PositionableRandomVec3 = {} + local angle = math.random() * math.pi*2; + PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; + PositionableRandomVec3.y = PositionablePointVec3.y + PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; + + self:T3( PositionableRandomVec3 ) + return PositionableRandomVec3 + else + self:E("Radius is nil, returning the PointVec3 of the POSITIONABLE", PositionablePointVec3) + return PositionablePointVec3 + end end return nil diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index d8de438d3..f5bf0fe33 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170327_1145' ) +env.info( 'Moose Generation Timestamp: 20170327_1159' ) local base = _G Include = {} @@ -13544,6 +13544,8 @@ end -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The 3D point vector of the POSITIONABLE. -- @return #nil The POSITIONABLE is not existing or alive. +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function POSITIONABLE:GetRandomVec3( Radius ) self:F2( self.PositionableName ) @@ -13551,14 +13553,20 @@ function POSITIONABLE:GetRandomVec3( Radius ) if DCSPositionable then local PositionablePointVec3 = DCSPositionable:getPosition().p - local PositionableRandomVec3 = {} - local angle = math.random() * math.pi*2; - PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; - PositionableRandomVec3.y = PositionablePointVec3.y - PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; - self:T3( PositionableRandomVec3 ) - return PositionableRandomVec3 + if Radius then + local PositionableRandomVec3 = {} + local angle = math.random() * math.pi*2; + PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; + PositionableRandomVec3.y = PositionablePointVec3.y + PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; + + self:T3( PositionableRandomVec3 ) + return PositionableRandomVec3 + else + self:E("Radius is nil, returning the Vec3 of the POSITIONABLE", PositionablePointVec3) + return PositionablePointVec3 + end end return nil @@ -16548,10 +16556,12 @@ end -- @param #GROUP self -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The random 3D point vector around the first UNIT of the GROUP. --- @return #nil The GROUP is invalid or empty +-- @return #nil The GROUP is invalid or empty +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function GROUP:GetRandomVec3(Radius) self:F2(self.GroupName) - + local FirstUnit = self:GetUnit(1) if FirstUnit then diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index d8de438d3..f5bf0fe33 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20170327_1145' ) +env.info( 'Moose Generation Timestamp: 20170327_1159' ) local base = _G Include = {} @@ -13544,6 +13544,8 @@ end -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The 3D point vector of the POSITIONABLE. -- @return #nil The POSITIONABLE is not existing or alive. +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function POSITIONABLE:GetRandomVec3( Radius ) self:F2( self.PositionableName ) @@ -13551,14 +13553,20 @@ function POSITIONABLE:GetRandomVec3( Radius ) if DCSPositionable then local PositionablePointVec3 = DCSPositionable:getPosition().p - local PositionableRandomVec3 = {} - local angle = math.random() * math.pi*2; - PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; - PositionableRandomVec3.y = PositionablePointVec3.y - PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; - self:T3( PositionableRandomVec3 ) - return PositionableRandomVec3 + if Radius then + local PositionableRandomVec3 = {} + local angle = math.random() * math.pi*2; + PositionableRandomVec3.x = PositionablePointVec3.x + math.cos( angle ) * math.random() * Radius; + PositionableRandomVec3.y = PositionablePointVec3.y + PositionableRandomVec3.z = PositionablePointVec3.z + math.sin( angle ) * math.random() * Radius; + + self:T3( PositionableRandomVec3 ) + return PositionableRandomVec3 + else + self:E("Radius is nil, returning the Vec3 of the POSITIONABLE", PositionablePointVec3) + return PositionablePointVec3 + end end return nil @@ -16548,10 +16556,12 @@ end -- @param #GROUP self -- @param #number Radius -- @return Dcs.DCSTypes#Vec3 The random 3D point vector around the first UNIT of the GROUP. --- @return #nil The GROUP is invalid or empty +-- @return #nil The GROUP is invalid or empty +-- @usage +-- -- If Radius is ignored, returns the Dcs.DCSTypes#Vec3 of first UNIT of the GROUP function GROUP:GetRandomVec3(Radius) self:F2(self.GroupName) - + local FirstUnit = self:GetUnit(1) if FirstUnit then