Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Applevangelist
2024-01-03 18:06:15 +01:00
4 changed files with 70 additions and 6 deletions

View File

@@ -19,7 +19,7 @@
-- --
-- ## Missions: -- ## Missions:
-- --
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting) -- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Escort)
-- --
-- === -- ===
-- --

View File

@@ -19,7 +19,7 @@
-- --
-- ## Missions: -- ## Missions:
-- --
-- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/ESC%20-%20Escorting) -- [ESC - Escorting](https://github.com/FlightControl-Master/MOOSE_MISSIONS/tree/master/AI/AI_Escort)
-- --
-- === -- ===
-- --

View File

@@ -455,7 +455,7 @@ do -- SET_BASE
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes. --- Gets a random object from the @{Core.Set#SET_BASE} and derived classes.
-- @param #SET_BASE self -- @param #SET_BASE self
-- @return Core.Base#BASE -- @return Core.Base#BASE or nil if none found or the SET is empty!
function SET_BASE:GetRandom() function SET_BASE:GetRandom()
local tablemax = 0 local tablemax = 0
for _,_ind in pairs(self.Index) do for _,_ind in pairs(self.Index) do
@@ -467,6 +467,23 @@ do -- SET_BASE
return RandomItem return RandomItem
end end
--- Gets a random object from the @{Core.Set#SET_BASE} and derived classes. A bit slower than @{#SET_BASE.GetRandom}() but tries to ensure you get an object back if the SET is not empty.
-- @param #SET_BASE self
-- @return Core.Base#BASE or nil if the SET is empty!
function SET_BASE:GetRandomSurely()
local tablemax = 0
local sorted = {}
for _,_obj in pairs(self.Set) do
tablemax = tablemax + 1
sorted[tablemax] = _obj
end
--local tablemax = table.maxn(self.Index)
--local RandomItem = self.Set[self.Index[math.random(1,tablemax)]]
local RandomItem = sorted[math.random(1,tablemax)]
self:T3( { RandomItem } )
return RandomItem
end
--- Retrieves the amount of objects in the @{Core.Set#SET_BASE} and derived classes. --- Retrieves the amount of objects in the @{Core.Set#SET_BASE} and derived classes.
-- @param #SET_BASE self -- @param #SET_BASE self
-- @return #number Count -- @return #number Count
@@ -8216,7 +8233,13 @@ do -- SET_SCENERY
-- @return Core.Point#COORDINATE The center coordinate of all the objects in the set. -- @return Core.Point#COORDINATE The center coordinate of all the objects in the set.
function SET_SCENERY:GetCoordinate() function SET_SCENERY:GetCoordinate()
local Coordinate = self:GetRandom():GetCoordinate() local Coordinate = COORDINATE:New({0,0,0})
local Item = self:GetRandomSurely()
if Item then
Coordinate:GetCoordinate()
end
local x1 = Coordinate.x local x1 = Coordinate.x
local x2 = Coordinate.x local x2 = Coordinate.x

View File

@@ -1,2 +1,43 @@
-- Automatic dynamic loading of development files, if they exists.
-- Try to load Moose as individual script files from <DcsInstallDir\Script\Moose
-- which should be a Junction link to the MOOSE repository subfolder "Moose Development\Moose".
-- This method is used by Moose developers and not mission builders.
ModuleLoader = 'Scripts/Moose/Modules.lua'
local f=io.open(ModuleLoader,"r")
if f~=nil then
io.close(f)
env.info( '*** MOOSE DYNAMIC INCLUDE START *** ' )
local base = _G
__Moose = {}
__Moose.Include = function( IncludeFile )
if not __Moose.Includes[ IncludeFile ] then
__Moose.Includes[IncludeFile] = IncludeFile
local f = assert( base.loadfile( IncludeFile ) )
if f == nil then
error ("Moose: Could not load Moose file " .. IncludeFile )
else
env.info( "Moose: " .. IncludeFile .. " dynamically loaded." )
return f()
end
end
end
__Moose.Includes = {}
__Moose.Include( 'Scripts/Moose/Modules.lua' )
BASE:TraceOnOff( true )
env.info( '*** MOOSE INCLUDE END *** ' )
-- Skip the static part of this file completly
do return end
end
-- Individual Moose files are not found. Use the static code below.
env.info( '*** MOOSE STATIC INCLUDE START *** ' ) env.info( '*** MOOSE STATIC INCLUDE START *** ' )