Merge pull request #1326 from FlightControl-Master/FF/Develop

Fixes
This commit is contained in:
Frank 2020-05-16 13:14:55 +02:00 committed by GitHub
commit be1f8cde34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 73 additions and 7 deletions

View File

@ -446,6 +446,47 @@ do -- COORDINATE
return gotunits, gotstatics, gotscenery, Units, Statics, Scenery
end
--- Scan/find UNITS within a certain radius around the coordinate using the world.searchObjects() DCS API function.
-- @param #COORDINATE self
-- @param #number radius (Optional) Scan radius in meters. Default 100 m.
-- @return Core.Set#SET_UNIT Set of units.
function COORDINATE:ScanUnits(radius)
local _,_,_,units=self:ScanObjects(radius, true, false, false)
local set=SET_UNIT:New()
for _,unit in pairs(units) do
set:AddUnit(unit)
end
return set
end
--- Find the closest unit to the COORDINATE within a certain radius.
-- @param #COORDINATE self
-- @param #number radius Scan radius in meters. Default 100 m.
-- @return Wrapper.Unit#UNIT The closest unit or #nil if no unit is inside the given radius.
function COORDINATE:FindClosestUnit(radius)
local units=self:ScanUnits(radius)
local umin=nil --Wrapper.Unit#UNIT
local dmin=math.huge
for _,_unit in pairs(units.Set) do
local unit=_unit --Wrapper.Unit#UNIT
local coordinate=unit:GetCoordinate()
local d=self:Get2DDistance(coordinate)
if d<dmin then
dmin=d
umin=unit
end
end
return umin
end
--- Calculate the distance from a reference @{#COORDINATE}.
-- @param #COORDINATE self

View File

@ -121,7 +121,7 @@ function RADIOQUEUE:Start(delay, dt)
self.dt=dt or 0.01
-- Debug message.
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, delay, dt))
self:I(self.lid..string.format("Starting RADIOQUEUE %s on Frequency %.2f MHz [modulation=%d] in %.1f seconds (dt=%.3f sec)", self.alias, self.frequency/1000000, self.modulation, self.delay, self.dt))
-- Start Scheduler.
if self.schedonce then

View File

@ -59,14 +59,19 @@ do -- UserFlag
--- Set the userflag to a given Number.
-- @param #USERFLAG self
-- @param #number Number The number value to be checked if it is the same as the userflag.
-- @param #number Delay Delay in seconds, before the flag is set.
-- @return #USERFLAG The userflag instance.
-- @usage
-- local BlueVictory = USERFLAG:New( "VictoryBlue" )
-- BlueVictory:Set( 100 ) -- Set the UserFlag VictoryBlue to 100.
--
function USERFLAG:Set( Number ) --R2.3
function USERFLAG:Set( Number, Delay ) --R2.3
trigger.action.setUserFlag( self.UserFlagName, Number )
if Delay and Delay>0 then
self:ScheduleOnce(Delay, USERFLAG.Set, self, Number)
else
trigger.action.setUserFlag( self.UserFlagName, Number )
end
return self
end

View File

@ -244,8 +244,8 @@ end
-- @param Core.Event#EVENTDATA EventData
function CLEANUP_AIRBASE.__:OnEventBirth( EventData )
self:F( { EventData } )
if EventData.IniUnit:IsAlive() ~= nil then
if EventData and EventData.IniUnit and EventData.IniUnit:IsAlive() ~= nil then
if self:IsInAirbase( EventData.IniUnit:GetVec2() ) then
self.CleanUpList[EventData.IniDCSUnitName] = {}
self.CleanUpList[EventData.IniDCSUnitName].CleanUpUnit = EventData.IniUnit

View File

@ -1764,7 +1764,7 @@ _WAREHOUSEDB = {
--- Warehouse class version.
-- @field #string version
WAREHOUSE.version="1.0.1"
WAREHOUSE.version="1.0.2"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Warehouse todo list.
@ -8404,7 +8404,7 @@ end
-- @return #string Text about warehouse stock
function WAREHOUSE:_UpdateWarehouseMarkText()
if self.makerOn then
if self.markerOn then
-- Create a mark with the current assets in stock.
if self.markerid~=nil then

View File

@ -602,6 +602,26 @@ function POSITIONABLE:IsGround()
end
--- Returns if the unit is of ship category.
-- @param #POSITIONABLE self
-- @return #boolean Ship category evaluation result.
function POSITIONABLE:IsShip()
self:F2()
local DCSUnit = self:GetDCSObject()
if DCSUnit then
local UnitDescriptor = DCSUnit:getDesc()
local IsShip = ( UnitDescriptor.category == Unit.Category.SHIP )
return IsShip
end
return nil
end
--- Returns true if the POSITIONABLE is in the air.
-- Polymorphic, is overridden in GROUP and UNIT.
-- @param Wrapper.Positionable#POSITIONABLE self