From 3aee8a49c1c5d71adddd1ec655cd993bb9a3aa21 Mon Sep 17 00:00:00 2001 From: Applevangelist Date: Fri, 18 Mar 2022 07:39:48 +0100 Subject: [PATCH] Added CONTROLLABLE SetSpeed() and SetAltitude() --- .../Moose/Wrapper/Controllable.lua | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 963558549..70c048093 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -3770,3 +3770,44 @@ function POSITIONABLE:IsSubmarine() return nil end + +--- Sets the controlled group to go the specified speed in meters per second. +-- @param #CONTROLLABLE self +-- @param #number Speed Speed in meters per second +-- @param #boolean Keep (Optional) When set to true will maintain that speed on passing waypoints. If no present or false the controlled group will return to the speed as defined by their route. +-- @return #CONTROLLABLE self +function CONTROLLABLE:SetSpeed(Speed, Keep) + self:F2( { self.ControllableName } ) + -- Set default if not specified. + local speed = Speed or 5 + local DCSControllable = self:GetDCSObject() + if DCSControllable then + local Controller = self:_GetController() + if Controller then + Controller:setSpeed(speed, Keep) + end + end + return self +end + +--- [AIR] Sets the controlled aircraft group to the specified altitude in meters. +-- @param #CONTROLLABLE self +-- @param #number Altitude Altitude in meters +-- @param #boolean Keep (Optional) When set to true will maintain that altitude on passing waypoints. If no present or false the controlled group will return to the altitude as defined by their route. +-- @param #string AltType (Optional) Will specify the altitude type used. If nil the altitude type of the current waypoint will be used. Accepted values are "BARO" and "RADIO". +-- @return #CONTROLLABLE self +function CONTROLLABLE:SetAltitude(Altitude, Keep, AltType) + self:F2( { self.ControllableName } ) + -- Set default if not specified. + local altitude = Altitude or 1000 + local DCSControllable = self:GetDCSObject() + if DCSControllable then + local Controller = self:_GetController() + if Controller then + if self:IsAir() then + Controller:setAltitude(altitude, Keep, AltType) + end + end + end + return self +end \ No newline at end of file