* Remove dependencies from UTILS.Routines
* Remove UTILS.Routines
This commit is contained in:
Applevangelist 2023-09-08 11:14:36 +02:00
parent 326d4b3135
commit e95a9525c6
15 changed files with 81 additions and 2421 deletions

View File

@ -34,7 +34,7 @@ local _TraceClassMethod = {}
local _ClassID = 0 local _ClassID = 0
--- @type BASE -- @type BASE
-- @field ClassName The name of the class. -- @field ClassName The name of the class.
-- @field ClassID The ID number of the class. -- @field ClassID The ID number of the class.
-- @field ClassNameAndID The name of the class concatenated with the ID number of the class. -- @field ClassNameAndID The name of the class concatenated with the ID number of the class.
@ -201,10 +201,10 @@ BASE = {
Scheduler = nil, Scheduler = nil,
} }
--- @field #BASE.__ -- @field #BASE.__
BASE.__ = {} BASE.__ = {}
--- @field #BASE._ -- @field #BASE._
BASE._ = { BASE._ = {
Schedules = {}, --- Contains the Schedulers Active Schedules = {}, --- Contains the Schedulers Active
} }
@ -229,7 +229,7 @@ FORMATION = {
-- @param #BASE self -- @param #BASE self
-- @return #BASE -- @return #BASE
function BASE:New() function BASE:New()
--local self = routines.utils.deepCopy( self ) -- Create a new self instance --local self = UTILS.DeepCopy( self ) -- Create a new self instance
local self = UTILS.DeepCopy(self) local self = UTILS.DeepCopy(self)
_ClassID = _ClassID + 1 _ClassID = _ClassID + 1
@ -252,7 +252,7 @@ end
function BASE:Inherit( Child, Parent ) function BASE:Inherit( Child, Parent )
-- Create child. -- Create child.
local Child = routines.utils.deepCopy( Child ) local Child = UTILS.DeepCopy( Child )
if Child ~= nil then if Child ~= nil then
@ -1167,7 +1167,7 @@ function BASE:_F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if DebugInfoFrom then if DebugInfoFrom then
LineFrom = DebugInfoFrom.currentline LineFrom = DebugInfoFrom.currentline
end end
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "F", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "F", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
end end
end end
end end
@ -1241,7 +1241,7 @@ function BASE:_T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam )
if DebugInfoFrom then if DebugInfoFrom then
LineFrom = DebugInfoFrom.currentline LineFrom = DebugInfoFrom.currentline
end end
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s", LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s", LineCurrent, LineFrom, "T", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
end end
end end
end end
@ -1311,9 +1311,9 @@ function BASE:E( Arguments )
LineFrom = DebugInfoFrom.currentline LineFrom = DebugInfoFrom.currentline
end end
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "E", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
else else
env.info( string.format( "%1s:%30s%05d(%s)", "E", self.ClassName, self.ClassID, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%1s:%30s%05d(%s)", "E", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
end end
end end
@ -1338,9 +1338,9 @@ function BASE:I( Arguments )
LineFrom = DebugInfoFrom.currentline LineFrom = DebugInfoFrom.currentline
end end
env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "I", self.ClassName, self.ClassID, Function, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%6d(%6d)/%1s:%30s%05d.%s(%s)", LineCurrent, LineFrom, "I", self.ClassName, self.ClassID, Function, UTILS.BasicSerialize( Arguments ) ) )
else else
env.info( string.format( "%1s:%30s%05d(%s)", "I", self.ClassName, self.ClassID, routines.utils.oneLineSerialize( Arguments ) ) ) env.info( string.format( "%1s:%30s%05d(%s)", "I", self.ClassName, self.ClassID, UTILS.BasicSerialize( Arguments ) ) )
end end
end end

View File

@ -32,7 +32,6 @@
-- @image Core_Database.JPG -- @image Core_Database.JPG
--- DATABASE class.
-- @type DATABASE -- @type DATABASE
-- @field #string ClassName Name of the class. -- @field #string ClassName Name of the class.
-- @field #table Templates Templates: Units, Groups, Statics, ClientsByName, ClientsByID. -- @field #table Templates Templates: Units, Groups, Statics, ClientsByName, ClientsByID.
@ -1849,13 +1848,13 @@ function DATABASE:GetFlightControl(airbasename)
return self.FLIGHTCONTROLS[airbasename] return self.FLIGHTCONTROLS[airbasename]
end end
--- @param #DATABASE self -- @param #DATABASE self
function DATABASE:_RegisterTemplates() function DATABASE:_RegisterTemplates()
self:F2() self:F2()
self.Navpoints = {} self.Navpoints = {}
self.UNITS = {} self.UNITS = {}
--Build routines.db.units and self.Navpoints --Build self.Navpoints
for CoalitionName, coa_data in pairs(env.mission.coalition) do for CoalitionName, coa_data in pairs(env.mission.coalition) do
self:T({CoalitionName=CoalitionName}) self:T({CoalitionName=CoalitionName})
@ -1877,7 +1876,7 @@ function DATABASE:_RegisterTemplates()
for nav_ind, nav_data in pairs(coa_data.nav_points) do for nav_ind, nav_data in pairs(coa_data.nav_points) do
if type(nav_data) == 'table' then if type(nav_data) == 'table' then
self.Navpoints[CoalitionName][nav_ind] = routines.utils.deepCopy(nav_data) self.Navpoints[CoalitionName][nav_ind] = UTILS.DeepCopy(nav_data)
self.Navpoints[CoalitionName][nav_ind]['name'] = nav_data.callsignStr -- name is a little bit more self-explanatory. self.Navpoints[CoalitionName][nav_ind]['name'] = nav_data.callsignStr -- name is a little bit more self-explanatory.
self.Navpoints[CoalitionName][nav_ind]['point'] = {} -- point is used by SSE, support it. self.Navpoints[CoalitionName][nav_ind]['point'] = {} -- point is used by SSE, support it.

View File

@ -208,7 +208,7 @@ SCHEDULER = {
-- @param #number RandomizeFactor Specifies a randomization factor between 0 and 1 to randomize the Repeat. -- @param #number RandomizeFactor Specifies a randomization factor between 0 and 1 to randomize the Repeat.
-- @param #number Stop Specifies the amount of seconds when the scheduler will be stopped. -- @param #number Stop Specifies the amount of seconds when the scheduler will be stopped.
-- @return #SCHEDULER self. -- @return #SCHEDULER self.
-- @return #table The ScheduleID of the planned schedule. -- @return #string The ScheduleID of the planned schedule.
function SCHEDULER:New( MasterObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop ) function SCHEDULER:New( MasterObject, SchedulerFunction, SchedulerArguments, Start, Repeat, RandomizeFactor, Stop )
local self = BASE:Inherit( self, BASE:New() ) -- #SCHEDULER local self = BASE:Inherit( self, BASE:New() ) -- #SCHEDULER

View File

@ -439,7 +439,7 @@ do -- SET_BASE
function SET_BASE:SetDatabase( BaseSet ) function SET_BASE:SetDatabase( BaseSet )
-- Copy the filter criteria of the BaseSet -- Copy the filter criteria of the BaseSet
local OtherFilter = routines.utils.deepCopy( BaseSet.Filter ) local OtherFilter = UTILS.DeepCopy( BaseSet.Filter )
self.Filter = OtherFilter self.Filter = OtherFilter
-- Now base the new Set on the BaseSet -- Now base the new Set on the BaseSet

View File

@ -1202,7 +1202,6 @@ function SPAWN:InitCleanUp( SpawnCleanUpInterval )
local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup() local SpawnGroup, SpawnCursor = self:GetFirstAliveGroup()
self:T( { "CleanUp Scheduler:", SpawnGroup } ) self:T( { "CleanUp Scheduler:", SpawnGroup } )
-- self.CleanUpFunction = routines.scheduleFunction( self._SpawnCleanUpScheduler, { self }, timer.getTime() + 1, SpawnCleanUpInterval )
self.CleanUpScheduler = SCHEDULER:New( self, self._SpawnCleanUpScheduler, {}, 1, SpawnCleanUpInterval, 0.2 ) self.CleanUpScheduler = SCHEDULER:New( self, self._SpawnCleanUpScheduler, {}, 1, SpawnCleanUpInterval, 0.2 )
return self return self
end end

View File

@ -967,7 +967,7 @@ do -- Spot
end -- Spot end -- Spot
do -- Controller do -- Controller
--- Controller is an object that performs A.I.-routines. Other words controller is an instance of A.I.. Controller stores current main task, active enroute tasks and behavior options. Controller performs commands. Please, read DCS A-10C GUI Manual EN.pdf chapter "Task Planning for Unit Groups", page 91 to understand A.I. system of DCS:A-10C. --- Controller is an object that performs A.I.-tasks. Other words controller is an instance of A.I.. Controller stores current main task, active enroute tasks and behavior options. Controller performs commands. Please, read DCS A-10C GUI Manual EN.pdf chapter "Task Planning for Unit Groups", page 91 to understand A.I. system of DCS:A-10C.
-- --
-- This class has 2 types of functions: -- This class has 2 types of functions:
-- --

View File

@ -109,7 +109,7 @@
--- @type ESCORT -- @type ESCORT
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
-- @field Wrapper.Client#CLIENT EscortClient -- @field Wrapper.Client#CLIENT EscortClient
-- @field Wrapper.Group#GROUP EscortGroup -- @field Wrapper.Group#GROUP EscortGroup
@ -600,7 +600,7 @@ function ESCORT:MenuReportTargets( Seconds )
self.EscortMenuAttackNearbyTargets = MENU_GROUP:New( self.EscortClient:GetGroup(), "Attack targets", self.EscortMenu ) self.EscortMenuAttackNearbyTargets = MENU_GROUP:New( self.EscortClient:GetGroup(), "Attack targets", self.EscortMenu )
self.ReportTargetsScheduler = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds ) self.ReportTargetsScheduler, self.ReportTargetsSchedulerID = SCHEDULER:New( self, self._ReportTargetsScheduler, {}, 1, Seconds )
return self return self
end end
@ -693,7 +693,7 @@ function ESCORT:MenuResumeMission()
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_HoldPosition( OrbitGroup, OrbitHeight, OrbitSeconds ) function ESCORT:_HoldPosition( OrbitGroup, OrbitHeight, OrbitSeconds )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -733,7 +733,7 @@ function ESCORT:_HoldPosition( OrbitGroup, OrbitHeight, OrbitSeconds )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_JoinUpAndFollow( Distance ) function ESCORT:_JoinUpAndFollow( Distance )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -766,7 +766,7 @@ function ESCORT:JoinUpAndFollow( EscortGroup, EscortClient, Distance )
EscortGroup:MessageToClient( "Rejoining and Following at " .. Distance .. "!", 30, EscortClient ) EscortGroup:MessageToClient( "Rejoining and Following at " .. Distance .. "!", 30, EscortClient )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_Flare( Color, Message ) function ESCORT:_Flare( Color, Message )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -776,7 +776,7 @@ function ESCORT:_Flare( Color, Message )
EscortGroup:MessageToClient( Message, 10, EscortClient ) EscortGroup:MessageToClient( Message, 10, EscortClient )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_Smoke( Color, Message ) function ESCORT:_Smoke( Color, Message )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -787,7 +787,7 @@ function ESCORT:_Smoke( Color, Message )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_ReportNearbyTargetsNow() function ESCORT:_ReportNearbyTargetsNow()
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -809,12 +809,12 @@ function ESCORT:_SwitchReportNearbyTargets( ReportTargets )
self.ReportTargetsScheduler:Schedule( self, self._ReportTargetsScheduler, {}, 1, 30 ) self.ReportTargetsScheduler:Schedule( self, self._ReportTargetsScheduler, {}, 1, 30 )
end end
else else
routines.removeFunction( self.ReportTargetsScheduler ) self.ReportTargetsScheduler:Remove(self.ReportTargetsSchedulerID)
self.ReportTargetsScheduler = nil self.ReportTargetsScheduler = nil
end end
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_ScanTargets( ScanDuration ) function ESCORT:_ScanTargets( ScanDuration )
local EscortGroup = self.EscortGroup -- Wrapper.Group#GROUP local EscortGroup = self.EscortGroup -- Wrapper.Group#GROUP
@ -844,7 +844,7 @@ function ESCORT:_ScanTargets( ScanDuration )
end end
--- @param Wrapper.Group#GROUP EscortGroup -- @param Wrapper.Group#GROUP EscortGroup
function _Resume( EscortGroup ) function _Resume( EscortGroup )
env.info( '_Resume' ) env.info( '_Resume' )
@ -856,7 +856,7 @@ function _Resume( EscortGroup )
end end
--- @param #ESCORT self -- @param #ESCORT self
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
function ESCORT:_AttackTarget( DetectedItem ) function ESCORT:_AttackTarget( DetectedItem )
@ -877,7 +877,7 @@ function ESCORT:_AttackTarget( DetectedItem )
local Tasks = {} local Tasks = {}
DetectedSet:ForEachUnit( DetectedSet:ForEachUnit(
--- @param Wrapper.Unit#UNIT DetectedUnit -- @param Wrapper.Unit#UNIT DetectedUnit
function( DetectedUnit, Tasks ) function( DetectedUnit, Tasks )
if DetectedUnit:IsAlive() then if DetectedUnit:IsAlive() then
Tasks[#Tasks+1] = EscortGroup:TaskAttackUnit( DetectedUnit ) Tasks[#Tasks+1] = EscortGroup:TaskAttackUnit( DetectedUnit )
@ -900,7 +900,7 @@ function ESCORT:_AttackTarget( DetectedItem )
local Tasks = {} local Tasks = {}
DetectedSet:ForEachUnit( DetectedSet:ForEachUnit(
--- @param Wrapper.Unit#UNIT DetectedUnit -- @param Wrapper.Unit#UNIT DetectedUnit
function( DetectedUnit, Tasks ) function( DetectedUnit, Tasks )
if DetectedUnit:IsAlive() then if DetectedUnit:IsAlive() then
Tasks[#Tasks+1] = EscortGroup:TaskFireAtPoint( DetectedUnit:GetVec2(), 50 ) Tasks[#Tasks+1] = EscortGroup:TaskFireAtPoint( DetectedUnit:GetVec2(), 50 )
@ -921,7 +921,7 @@ function ESCORT:_AttackTarget( DetectedItem )
end end
--- ---
--- @param #ESCORT self -- @param #ESCORT self
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem -- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem ) function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem )
@ -939,7 +939,7 @@ function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem )
local Tasks = {} local Tasks = {}
DetectedSet:ForEachUnit( DetectedSet:ForEachUnit(
--- @param Wrapper.Unit#UNIT DetectedUnit -- @param Wrapper.Unit#UNIT DetectedUnit
function( DetectedUnit, Tasks ) function( DetectedUnit, Tasks )
if DetectedUnit:IsAlive() then if DetectedUnit:IsAlive() then
Tasks[#Tasks+1] = EscortGroupAttack:TaskAttackUnit( DetectedUnit ) Tasks[#Tasks+1] = EscortGroupAttack:TaskAttackUnit( DetectedUnit )
@ -961,7 +961,7 @@ function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem )
local Tasks = {} local Tasks = {}
DetectedSet:ForEachUnit( DetectedSet:ForEachUnit(
--- @param Wrapper.Unit#UNIT DetectedUnit -- @param Wrapper.Unit#UNIT DetectedUnit
function( DetectedUnit, Tasks ) function( DetectedUnit, Tasks )
if DetectedUnit:IsAlive() then if DetectedUnit:IsAlive() then
Tasks[#Tasks+1] = EscortGroupAttack:TaskFireAtPoint( DetectedUnit:GetVec2(), 50 ) Tasks[#Tasks+1] = EscortGroupAttack:TaskFireAtPoint( DetectedUnit:GetVec2(), 50 )
@ -981,7 +981,7 @@ function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_ROE( EscortROEFunction, EscortROEMessage ) function ESCORT:_ROE( EscortROEFunction, EscortROEMessage )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -991,7 +991,7 @@ function ESCORT:_ROE( EscortROEFunction, EscortROEMessage )
EscortGroup:MessageToClient( EscortROEMessage, 10, EscortClient ) EscortGroup:MessageToClient( EscortROEMessage, 10, EscortClient )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_ROT( EscortROTFunction, EscortROTMessage ) function ESCORT:_ROT( EscortROTFunction, EscortROTMessage )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -1001,7 +1001,7 @@ function ESCORT:_ROT( EscortROTFunction, EscortROTMessage )
EscortGroup:MessageToClient( EscortROTMessage, 10, EscortClient ) EscortGroup:MessageToClient( EscortROTMessage, 10, EscortClient )
end end
--- @param #MENUPARAM MenuParam -- @param #MENUPARAM MenuParam
function ESCORT:_ResumeMission( WayPoint ) function ESCORT:_ResumeMission( WayPoint )
local EscortGroup = self.EscortGroup local EscortGroup = self.EscortGroup
@ -1036,7 +1036,7 @@ function ESCORT:RegisterRoute()
return TaskPoints return TaskPoints
end end
--- @param Functional.Escort#ESCORT self -- @param Functional.Escort#ESCORT self
function ESCORT:_FollowScheduler() function ESCORT:_FollowScheduler()
self:F( { self.FollowDistance } ) self:F( { self.FollowDistance } )

View File

@ -68,7 +68,7 @@
-- @image Missile_Trainer.JPG -- @image Missile_Trainer.JPG
--- @type MISSILETRAINER -- @type MISSILETRAINER
-- @field Core.Set#SET_CLIENT DBClients -- @field Core.Set#SET_CLIENT DBClients
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
@ -210,7 +210,7 @@ function MISSILETRAINER:New( Distance, Briefing )
-- self.DB:ForEachClient( -- self.DB:ForEachClient(
-- --- @param Wrapper.Client#CLIENT Client -- -- @param Wrapper.Client#CLIENT Client
-- function( Client ) -- function( Client )
-- --
-- ... actions ... -- ... actions ...
@ -560,7 +560,7 @@ function MISSILETRAINER:_AddBearing( Client, TrainerWeapon )
local DirectionVector = { x = PositionMissile.x - TargetVec3.x, y = PositionMissile.y - TargetVec3.y, z = PositionMissile.z - TargetVec3.z } local DirectionVector = { x = PositionMissile.x - TargetVec3.x, y = PositionMissile.y - TargetVec3.y, z = PositionMissile.z - TargetVec3.z }
local DirectionRadians = math.atan2( DirectionVector.z, DirectionVector.x ) local DirectionRadians = math.atan2( DirectionVector.z, DirectionVector.x )
--DirectionRadians = DirectionRadians + routines.getNorthCorrection( PositionTarget )
if DirectionRadians < 0 then if DirectionRadians < 0 then
DirectionRadians = DirectionRadians + 2 * math.pi DirectionRadians = DirectionRadians + 2 * math.pi
end end

View File

@ -10,7 +10,7 @@
-- @module Functional.Movement -- @module Functional.Movement
-- @image MOOSE.JPG -- @image MOOSE.JPG
--- @type MOVEMENT -- @type MOVEMENT
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
--- ---
@ -55,7 +55,6 @@ end
--- Call this function to start the MOVEMENT scheduling. --- Call this function to start the MOVEMENT scheduling.
function MOVEMENT:ScheduleStart() function MOVEMENT:ScheduleStart()
self:F() self:F()
--self.MoveFunction = routines.scheduleFunction( self._Scheduler, { self }, timer.getTime() + 1, 120 )
self.MoveFunction = SCHEDULER:New( self, self._Scheduler, {}, 1, 120 ) self.MoveFunction = SCHEDULER:New( self, self._Scheduler, {}, 1, 120 )
end end

View File

@ -1,5 +1,4 @@
__Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' ) __Moose.Include( 'Scripts/Moose/Utilities/Enums.lua' )
__Moose.Include( 'Scripts/Moose/Utilities/Routines.lua' )
__Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' ) __Moose.Include( 'Scripts/Moose/Utilities/Utils.lua' )
__Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' ) __Moose.Include( 'Scripts/Moose/Utilities/Profiler.lua' )
__Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' ) __Moose.Include( 'Scripts/Moose/Utilities/Templates.lua' )

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@
-- @image MOOSE.JPG -- @image MOOSE.JPG
--- @type SMOKECOLOR -- @type SMOKECOLOR
-- @field Green -- @field Green
-- @field Red -- @field Red
-- @field White -- @field White
@ -22,7 +22,7 @@
SMOKECOLOR = trigger.smokeColor -- #SMOKECOLOR SMOKECOLOR = trigger.smokeColor -- #SMOKECOLOR
--- @type FLARECOLOR -- @type FLARECOLOR
-- @field Green -- @field Green
-- @field Red -- @field Red
-- @field White -- @field White
@ -300,14 +300,14 @@ end
-- @return #string Table as a string. -- @return #string Table as a string.
UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function UTILS.OneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
local lookup_table = {} lookup_table = {}
local function _Serialize( tbl ) local function _Serialize( tbl )
if type(tbl) == 'table' then --function only works for tables! if type(tbl) == 'table' then --function only works for tables!
if lookup_table[tbl] then if lookup_table[tbl] then
return lookup_table[tbl] return lookup_table[object]
end end
local tbl_str = {} local tbl_str = {}
@ -324,7 +324,7 @@ local lookup_table = {}
ind_str[#ind_str + 1] = ']=' ind_str[#ind_str + 1] = ']='
else --must be a string else --must be a string
ind_str[#ind_str + 1] = '[' ind_str[#ind_str + 1] = '['
ind_str[#ind_str + 1] = routines.utils.basicSerialize(ind) ind_str[#ind_str + 1] = UTILS.BasicSerialize(ind)
ind_str[#ind_str + 1] = ']=' ind_str[#ind_str + 1] = ']='
end end
@ -335,7 +335,7 @@ local lookup_table = {}
tbl_str[#tbl_str + 1] = table.concat(ind_str) tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str) tbl_str[#tbl_str + 1] = table.concat(val_str)
elseif type(val) == 'string' then elseif type(val) == 'string' then
val_str[#val_str + 1] = routines.utils.basicSerialize(val) val_str[#val_str + 1] = UTILS.BasicSerialize(val)
val_str[#val_str + 1] = ',' val_str[#val_str + 1] = ','
tbl_str[#tbl_str + 1] = table.concat(ind_str) tbl_str[#tbl_str + 1] = table.concat(ind_str)
tbl_str[#tbl_str + 1] = table.concat(val_str) tbl_str[#tbl_str + 1] = table.concat(val_str)
@ -358,7 +358,7 @@ local lookup_table = {}
tbl_str[#tbl_str + 1] = "f() " .. tostring(ind) tbl_str[#tbl_str + 1] = "f() " .. tostring(ind)
tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it tbl_str[#tbl_str + 1] = ',' --I think this is right, I just added it
else else
env.info('unable to serialize value type ' .. routines.utils.basicSerialize(type(val)) .. ' at index ' .. tostring(ind)) env.info('unable to serialize value type ' .. UTILS.BasicSerialize(type(val)) .. ' at index ' .. tostring(ind))
env.info( debug.traceback() ) env.info( debug.traceback() )
end end
@ -426,10 +426,12 @@ UTILS.BasicSerialize = function(s)
if s == nil then if s == nil then
return "\"\"" return "\"\""
else else
if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'table') or (type(s) == 'userdata') ) then if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'userdata') ) then
return tostring(s) return tostring(s)
elseif type(s) == "table" then
return UTILS._OneLineSerialize(s)
elseif type(s) == 'string' then elseif type(s) == 'string' then
s = string.format('%q', s) s = string.format('(%s)', s)
return s return s
end end
end end

View File

@ -521,6 +521,26 @@ function CONTROLLABLE:TaskWrappedAction( DCSCommand, Index )
return DCSTaskWrappedAction return DCSTaskWrappedAction
end end
--- Return an Empty Task.
-- @param #CONTROLLABLE self
-- @return DCS#Task
function CONTROLLABLE:TaskEmptyTask()
local DCSTaskWrappedAction = {
["id"] = "WrappedAction",
["params"] = {
["action"] = {
["id"] = "Script",
["params"] = {
["command"] = "",
},
},
},
}
return DCSTaskWrappedAction
end
--- Set a Task at a Waypoint using a Route list. --- Set a Task at a Waypoint using a Route list.
-- @param #CONTROLLABLE self -- @param #CONTROLLABLE self
-- @param #table Waypoint The Waypoint! -- @param #table Waypoint The Waypoint!
@ -2809,7 +2829,7 @@ end
function CONTROLLABLE:GetTaskMission() function CONTROLLABLE:GetTaskMission()
self:F2( self.ControllableName ) self:F2( self.ControllableName )
return routines.utils.deepCopy( _DATABASE.Templates.Controllables[self.ControllableName].Template ) return UTILS.DeepCopy( _DATABASE.Templates.Controllables[self.ControllableName].Template )
end end
--- Return the mission route of the controllable. --- Return the mission route of the controllable.
@ -2818,7 +2838,7 @@ end
function CONTROLLABLE:GetTaskRoute() function CONTROLLABLE:GetTaskRoute()
self:F2( self.ControllableName ) self:F2( self.ControllableName )
return routines.utils.deepCopy( _DATABASE.Templates.Controllables[self.ControllableName].Template.route.points ) return UTILS.DeepCopy( _DATABASE.Templates.Controllables[self.ControllableName].Template.route.points )
end end
--- Return the route of a controllable by using the @{Core.Database#DATABASE} class. --- Return the route of a controllable by using the @{Core.Database#DATABASE} class.
@ -2854,7 +2874,7 @@ function CONTROLLABLE:CopyRoute( Begin, End, Randomize, Radius )
for TPointID = Begin + 1, #Template.route.points - End do for TPointID = Begin + 1, #Template.route.points - End do
if Template.route.points[TPointID] then if Template.route.points[TPointID] then
Points[#Points + 1] = routines.utils.deepCopy( Template.route.points[TPointID] ) Points[#Points + 1] = UTILS.DeepCopy( Template.route.points[TPointID] )
if Randomize then if Randomize then
if not Radius then if not Radius then
Radius = 500 Radius = 500
@ -5264,3 +5284,4 @@ function CONTROLLABLE:TaskAerobaticsBarrelRoll(TaskAerobatics,Repeats,InitAltitu
return TaskAerobatics return TaskAerobatics
end end

View File

@ -38,7 +38,7 @@
-- @image Wrapper_Group.JPG -- @image Wrapper_Group.JPG
--- @type GROUP -- @type GROUP
-- @extends Wrapper.Controllable#CONTROLLABLE -- @extends Wrapper.Controllable#CONTROLLABLE
-- @field #string GroupName The name of the group. -- @field #string GroupName The name of the group.
@ -91,7 +91,7 @@
-- --
-- Tasks[#Tasks+1] = HeliGroup:TaskFunction( "_Resume", { "''" } ) -- Tasks[#Tasks+1] = HeliGroup:TaskFunction( "_Resume", { "''" } )
-- --
-- --- @param Wrapper.Group#GROUP HeliGroup -- -- @param Wrapper.Group#GROUP HeliGroup
-- function _Resume( HeliGroup ) -- function _Resume( HeliGroup )
-- env.info( '_Resume' ) -- env.info( '_Resume' )
-- --
@ -2200,7 +2200,7 @@ end
function GROUP:GetTaskMission() function GROUP:GetTaskMission()
self:F2( self.GroupName ) self:F2( self.GroupName )
return routines.utils.deepCopy( _DATABASE.Templates.Groups[self.GroupName].Template ) return UTILS.DeepCopy( _DATABASE.Templates.Groups[self.GroupName].Template )
end end
--- Return the mission route of the group. --- Return the mission route of the group.
@ -2209,7 +2209,7 @@ end
function GROUP:GetTaskRoute() function GROUP:GetTaskRoute()
self:F2( self.GroupName ) self:F2( self.GroupName )
return routines.utils.deepCopy( _DATABASE.Templates.Groups[self.GroupName].Template.route.points ) return UTILS.DeepCopy( _DATABASE.Templates.Groups[self.GroupName].Template.route.points )
end end
--- Return the route of a group by using the global _DATABASE object (an instance of @{Core.Database#DATABASE}). --- Return the route of a group by using the global _DATABASE object (an instance of @{Core.Database#DATABASE}).
@ -2245,7 +2245,7 @@ function GROUP:CopyRoute( Begin, End, Randomize, Radius )
for TPointID = Begin + 1, #Template.route.points - End do for TPointID = Begin + 1, #Template.route.points - End do
if Template.route.points[TPointID] then if Template.route.points[TPointID] then
Points[#Points+1] = routines.utils.deepCopy( Template.route.points[TPointID] ) Points[#Points+1] = UTILS.DeepCopy( Template.route.points[TPointID] )
if Randomize then if Randomize then
if not Radius then if not Radius then
Radius = 500 Radius = 500

View File

@ -1,5 +1,4 @@
Utilities/Enums.lua Utilities/Enums.lua
Utilities/Routines.lua
Utilities/Utils.lua Utilities/Utils.lua
Utilities/Enums.lua Utilities/Enums.lua
Utilities/Profiler.lua Utilities/Profiler.lua