mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Formatting and typos (#1652)
* Formatting and typo fixes. General formatting and typo fixes. * Update STTS.lua Keep class table on separate lines.
This commit is contained in:
parent
2ba5215036
commit
32deb160ef
@ -11,7 +11,7 @@
|
||||
--
|
||||
-- DCS itself provides a lot of enumerators for various things. See [Enumerators](https://wiki.hoggitworld.com/view/Category:Enumerators) on Hoggit.
|
||||
--
|
||||
-- Other Moose classe also have enumerators. For example, the AIRBASE class has enumerators for airbase names.
|
||||
-- Other Moose classes also have enumerators. For example, the AIRBASE class has enumerators for airbase names.
|
||||
--
|
||||
-- @module ENUMS
|
||||
-- @image MOOSE.JPG
|
||||
@ -30,7 +30,7 @@ ENUMS = {}
|
||||
-- @type ENUMS.ROE
|
||||
-- @field #number WeaponFree AI will engage any enemy group it detects. Target prioritization is based based on the threat of the target.
|
||||
-- @field #number OpenFireWeaponFree AI will engage any enemy group it detects, but will prioritize targets specified in the groups tasking.
|
||||
-- @field #number OpenFire AI will engage only targets specified in its taskings.
|
||||
-- @field #number OpenFire AI will engage only targets specified in its tasking.
|
||||
-- @field #number ReturnFire AI will only engage threats that shoot first.
|
||||
-- @field #number WeaponHold AI will hold fire under all circumstances.
|
||||
ENUMS.ROE = {
|
||||
@ -67,7 +67,7 @@ ENUMS.AlarmState = {
|
||||
Red = 2,
|
||||
}
|
||||
|
||||
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerotor on hoggit wiki.
|
||||
--- Weapon types. See the [Weapon Flag](https://wiki.hoggitworld.com/view/DCS_enum_weapon_flag) enumerator on Hoggit wiki.
|
||||
-- @type ENUMS.WeaponFlag
|
||||
ENUMS.WeaponFlag={
|
||||
-- Bombs
|
||||
@ -111,7 +111,7 @@ ENUMS.WeaponFlag={
|
||||
--
|
||||
-- Bombs
|
||||
GuidedBomb = 14, -- (LGB + TvGB + SNSGB)
|
||||
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispencer + CandleBomb + ParachuteBomb)
|
||||
AnyUnguidedBomb = 2147485680, -- (HeBomb + Penetrator + NapalmBomb + FAEBomb + ClusterBomb + Dispenser + CandleBomb + ParachuteBomb)
|
||||
AnyBomb = 2147485694, -- (GuidedBomb + AnyUnguidedBomb)
|
||||
--- Rockets
|
||||
AnyRocket = 30720, -- LightRocket + MarkerRocket + CandleRocket + HeavyRocket
|
||||
@ -173,7 +173,7 @@ ENUMS.MissionTask={
|
||||
TRANSPORT="Transport",
|
||||
}
|
||||
|
||||
--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
|
||||
--- Formations (new). See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on Hoggit wiki.
|
||||
-- @type ENUMS.Formation
|
||||
ENUMS.Formation={}
|
||||
ENUMS.Formation.FixedWing={}
|
||||
@ -244,7 +244,7 @@ ENUMS.Formation.Vehicle.Cone="Cone"
|
||||
ENUMS.Formation.Vehicle.Diamond="Diamond"
|
||||
|
||||
--- Formations (old). The old format is a simplified version of the new formation enums, which allow more sophisticated settings.
|
||||
-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on hoggit wiki.
|
||||
-- See the [Formations](https://wiki.hoggitworld.com/view/DCS_enum_formation) on Hoggit wiki.
|
||||
-- @type ENUMS.FormationOld
|
||||
ENUMS.FormationOld={}
|
||||
ENUMS.FormationOld.FixedWing={}
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
-- @module Utilities.PROFILER
|
||||
-- @image MOOSE.JPG
|
||||
|
||||
|
||||
--- PROFILER class.
|
||||
-- @type PROFILER
|
||||
-- @field #string ClassName Name of the class.
|
||||
@ -25,7 +24,6 @@
|
||||
-- @field #number ThreshTtot Total time threshold. Only write output if total function CPU time is more than this value.
|
||||
-- @field #string fileNamePrefix Output file name prefix, e.g. "MooseProfiler".
|
||||
-- @field #string fileNameSuffix Output file name prefix, e.g. "txt"
|
||||
|
||||
--- *The emperor counsels simplicity. First principles. Of each particular thing, ask: What is it in itself, in its own constitution? What is its causal nature? *
|
||||
--
|
||||
-- ===
|
||||
@ -35,12 +33,11 @@
|
||||
-- # The PROFILER Concept
|
||||
--
|
||||
-- Profile your lua code. This tells you, which functions are called very often and which consume most real time.
|
||||
-- With this information you can optimize the perfomance of your code.
|
||||
-- With this information you can optimize the performance of your code.
|
||||
--
|
||||
-- # Prerequisites
|
||||
--
|
||||
-- The modules **os** and **lfs** need to be desanizied.
|
||||
--
|
||||
-- The modules **os** and **lfs** need to be de-sanitized.
|
||||
--
|
||||
-- # Start
|
||||
--
|
||||
@ -122,15 +119,15 @@ function PROFILER.Start(Delay, Duration)
|
||||
-- Check if os, io and lfs are available.
|
||||
local go = true
|
||||
if not os then
|
||||
env.error("ERROR: Profiler needs os to be desanitized!")
|
||||
env.error( "ERROR: Profiler needs os to be de-sanitized!" )
|
||||
go = false
|
||||
end
|
||||
if not io then
|
||||
env.error("ERROR: Profiler needs io to be desanitized!")
|
||||
env.error( "ERROR: Profiler needs io to be de-sanitized!" )
|
||||
go = false
|
||||
end
|
||||
if not lfs then
|
||||
env.error("ERROR: Profiler needs lfs to be desanitized!")
|
||||
env.error( "ERROR: Profiler needs lfs to be de-sanitized!" )
|
||||
go = false
|
||||
end
|
||||
if not go then
|
||||
@ -161,7 +158,6 @@ function PROFILER.Start(Delay, Duration)
|
||||
env.info( string.format( "- Output file \"%s\" in CSV format", PROFILER.getfilename( "csv" ) ) )
|
||||
env.info( '###############################################################################' )
|
||||
|
||||
|
||||
-- Message on screen
|
||||
local duration = Duration or 600
|
||||
trigger.action.outText( "### Profiler running ###", duration )
|
||||
@ -191,7 +187,6 @@ function PROFILER.Stop(Delay)
|
||||
-- Remove hook.
|
||||
debug.sethook()
|
||||
|
||||
|
||||
-- Run time game.
|
||||
local runTimeGame = timer.getTime() - PROFILER.TstartGame
|
||||
|
||||
@ -337,7 +332,6 @@ function PROFILER.printCSV(data, runTimeGame)
|
||||
g:close()
|
||||
end
|
||||
|
||||
|
||||
--- Write info to output file.
|
||||
-- @param #string ext Extension.
|
||||
-- @return #string File name.
|
||||
@ -385,25 +379,20 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||
local tforgen = nil -- #PROFILER.Data
|
||||
local tpairs = nil -- #PROFILER.Data
|
||||
|
||||
|
||||
for func, count in pairs( PROFILER.Counters ) do
|
||||
|
||||
local s, src, line, tm = PROFILER.getData( func )
|
||||
|
||||
if PROFILER.logUnknown == true then
|
||||
if s==nil then s="<Unknown>" end
|
||||
if s == nil then
|
||||
s = "<Unknown>"
|
||||
end
|
||||
end
|
||||
|
||||
if s ~= nil then
|
||||
|
||||
-- Profile data.
|
||||
local T=
|
||||
{ func=s,
|
||||
src=src,
|
||||
line=line,
|
||||
count=count,
|
||||
tm=tm,
|
||||
} --#PROFILER.Data
|
||||
local T = { func = s, src = src, line = line, count = count, tm = tm } -- #PROFILER.Data
|
||||
|
||||
-- Collect special cases. Somehow, e.g. "_copy" appears multiple times so we try to gather all data.
|
||||
if s == "_copy" then
|
||||
@ -473,7 +462,9 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||
env.info( "##############################################################################" )
|
||||
|
||||
-- Sort by total time.
|
||||
table.sort(t, function(a,b) return a.tm>b.tm end)
|
||||
table.sort( t, function( a, b )
|
||||
return a.tm > b.tm
|
||||
end )
|
||||
|
||||
-- Write data.
|
||||
PROFILER._flog( f, "" )
|
||||
@ -500,7 +491,9 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||
PROFILER.showTable( t, f, runTimeGame )
|
||||
|
||||
-- Sort by number of calls.
|
||||
table.sort(t, function(a,b) return a.tm/a.count>b.tm/b.count end)
|
||||
table.sort( t, function( a, b )
|
||||
return a.tm / a.count > b.tm / b.count
|
||||
end )
|
||||
|
||||
-- Detailed data.
|
||||
PROFILER._flog( f, "" )
|
||||
@ -513,7 +506,9 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||
PROFILER.showTable( t, f, runTimeGame )
|
||||
|
||||
-- Sort by number of calls.
|
||||
table.sort(t, function(a,b) return a.count>b.count end)
|
||||
table.sort( t, function( a, b )
|
||||
return a.count > b.count
|
||||
end )
|
||||
|
||||
-- Detailed data.
|
||||
PROFILER._flog( f, "" )
|
||||
@ -536,4 +531,3 @@ function PROFILER.showInfo(runTimeGame, runTimeOS)
|
||||
-- Print csv file.
|
||||
PROFILER.printCSV( t, runTimeGame )
|
||||
end
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
--- Various routines
|
||||
-- @module routines
|
||||
-- @image MOOSE.JPG
|
||||
|
||||
env.setErrorMessageBoxEnabled( false )
|
||||
|
||||
--- Extract of MIST functions.
|
||||
@ -9,7 +8,6 @@ env.setErrorMessageBoxEnabled(false)
|
||||
|
||||
routines = {}
|
||||
|
||||
|
||||
-- don't change these
|
||||
routines.majorVersion = 3
|
||||
routines.minorVersion = 3
|
||||
@ -46,7 +44,6 @@ routines.utils.deepCopy = function(object)
|
||||
return objectreturn
|
||||
end
|
||||
|
||||
|
||||
-- porting in Slmod's serialize_slmod2
|
||||
routines.utils.oneLineSerialize = function( tbl ) -- serialization of a table all on a single line, no comments, made to replace old get_table_string function
|
||||
|
||||
@ -142,7 +139,6 @@ routines.utils.basicSerialize = function(s)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
routines.utils.toDegree = function( angle )
|
||||
return angle * 180 / math.pi
|
||||
end
|
||||
@ -252,10 +248,6 @@ function routines.utils.get3DDist(point1, point2)
|
||||
return routines.vec.mag( { x = point1.x - point2.x, y = point1.y - point2.y, z = point1.z - point2.z } )
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-- 3D Vector manipulation
|
||||
routines.vec = {}
|
||||
|
||||
@ -295,16 +287,12 @@ routines.vec.rotateVec2 = function(vec2, theta)
|
||||
end
|
||||
---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
-- acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5.
|
||||
routines.tostringMGRS = function( MGRS, acc )
|
||||
if acc == 0 then
|
||||
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph
|
||||
else
|
||||
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format('%0' .. acc .. 'd', routines.utils.round(MGRS.Easting/(10^(5-acc)), 0))
|
||||
.. ' ' .. string.format('%0' .. acc .. 'd', routines.utils.round(MGRS.Northing/(10^(5-acc)), 0))
|
||||
return MGRS.UTMZone .. ' ' .. MGRS.MGRSDigraph .. ' ' .. string.format( '%0' .. acc .. 'd', routines.utils.round( MGRS.Easting / (10 ^ (5 - acc)), 0 ) ) .. ' ' .. string.format( '%0' .. acc .. 'd', routines.utils.round( MGRS.Northing / (10 ^ (5 - acc)), 0 ) )
|
||||
end
|
||||
end
|
||||
|
||||
@ -366,8 +354,7 @@ routines.tostringLL = function(lat, lon, acc, DMS)
|
||||
secFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||
end
|
||||
|
||||
return string.format('%02d', latDeg) .. ' ' .. string.format('%02d', latMin) .. '\' ' .. string.format(secFrmtStr, latSec) .. '"' .. latHemi .. ' '
|
||||
.. string.format('%02d', lonDeg) .. ' ' .. string.format('%02d', lonMin) .. '\' ' .. string.format(secFrmtStr, lonSec) .. '"' .. lonHemi
|
||||
return string.format( '%02d', latDeg ) .. ' ' .. string.format( '%02d', latMin ) .. '\' ' .. string.format( secFrmtStr, latSec ) .. '"' .. latHemi .. ' ' .. string.format( '%02d', lonDeg ) .. ' ' .. string.format( '%02d', lonMin ) .. '\' ' .. string.format( secFrmtStr, lonSec ) .. '"' .. lonHemi
|
||||
|
||||
else -- degrees, decimal minutes.
|
||||
latMin = routines.utils.round( latMin, acc )
|
||||
@ -391,8 +378,7 @@ routines.tostringLL = function(lat, lon, acc, DMS)
|
||||
minFrmtStr = '%0' .. width .. '.' .. acc .. 'f'
|
||||
end
|
||||
|
||||
return string.format('%02d', latDeg) .. ' ' .. string.format(minFrmtStr, latMin) .. '\'' .. latHemi .. ' '
|
||||
.. string.format('%02d', lonDeg) .. ' ' .. string.format(minFrmtStr, lonMin) .. '\'' .. lonHemi
|
||||
return string.format( '%02d', latDeg ) .. ' ' .. string.format( minFrmtStr, latMin ) .. '\'' .. latHemi .. ' ' .. string.format( '%02d', lonDeg ) .. ' ' .. string.format( minFrmtStr, lonMin ) .. '\'' .. lonHemi
|
||||
|
||||
end
|
||||
end
|
||||
@ -433,7 +419,6 @@ routines.getNorthCorrection = function(point) --gets the correction needed for
|
||||
return math.atan2( north_posit.z - point.z, north_posit.x - point.x )
|
||||
end
|
||||
|
||||
|
||||
do
|
||||
local idNum = 0
|
||||
|
||||
@ -489,14 +474,7 @@ function routines.getRandPointInCircle(point, radius, innerRadius)
|
||||
end
|
||||
|
||||
routines.goRoute = function( group, path )
|
||||
local misTask = {
|
||||
id = 'Mission',
|
||||
params = {
|
||||
route = {
|
||||
points = routines.utils.deepCopy(path),
|
||||
},
|
||||
},
|
||||
}
|
||||
local misTask = { id = 'Mission', params = { route = { points = routines.utils.deepCopy( path ) } } }
|
||||
if type( group ) == 'string' then
|
||||
group = Group.getByName( group )
|
||||
end
|
||||
@ -510,7 +488,6 @@ routines.goRoute = function(group, path)
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
-- Useful atomic functions from mist, ported.
|
||||
|
||||
routines.ground = {}
|
||||
@ -569,9 +546,7 @@ routines.ground.buildWP = function(point, overRideForm, overRideSpeed)
|
||||
end
|
||||
|
||||
wp.type = 'Turning Point'
|
||||
|
||||
return wp
|
||||
|
||||
end
|
||||
|
||||
routines.fixedWing.buildWP = function( point, WPtype, speed, alt, altType )
|
||||
@ -702,7 +677,6 @@ routines.groupToRandomPoint = function(vars)
|
||||
local headingDegrees = vars.headingDegrees
|
||||
local speed = vars.speed or routines.utils.kmphToMps( 20 )
|
||||
|
||||
|
||||
local useRoads
|
||||
if not vars.disableRoads then
|
||||
useRoads = true
|
||||
@ -729,7 +703,6 @@ routines.groupToRandomPoint = function(vars)
|
||||
offset.z = routines.utils.round( math.cos( heading + (math.pi / 2) ) * 50 + rndCoord.y, 3 )
|
||||
path[#path + 1] = routines.ground.buildWP( posStart, form, speed )
|
||||
|
||||
|
||||
if useRoads == true and ((point.x - posStart.x) ^ 2 + (point.z - posStart.z) ^ 2) ^ 0.5 > radius * 1.3 then
|
||||
path[#path + 1] = routines.ground.buildWP( { ['x'] = posStart.x + 11, ['z'] = posStart.z + 11 }, 'off_road', speed )
|
||||
path[#path + 1] = routines.ground.buildWP( posStart, 'on_road', speed )
|
||||
@ -742,8 +715,6 @@ routines.groupToRandomPoint = function(vars)
|
||||
path[#path + 1] = routines.ground.buildWP( rndCoord, form, speed )
|
||||
|
||||
routines.goRoute( group, path )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
routines.groupRandomDistSelf = function( gpData, dist, form, heading, speed )
|
||||
@ -752,8 +723,6 @@ routines.groupRandomDistSelf = function(gpData, dist, form, heading, speed)
|
||||
fakeZone.radius = dist or math.random( 300, 1000 )
|
||||
fakeZone.point = { x = pos.x, y, pos.y, z = pos.z }
|
||||
routines.groupToRandomZone( gpData, fakeZone, form, heading, speed )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
routines.groupToRandomZone = function( gpData, zone, form, heading, speed )
|
||||
@ -780,8 +749,6 @@ routines.groupToRandomZone = function(gpData, zone, form, heading, speed)
|
||||
vars.point = routines.utils.zoneToVec3( zone )
|
||||
|
||||
routines.groupToRandomPoint( vars )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
routines.isTerrainValid = function( coord, terrainTypes ) -- vec2/3 and enum or table of acceptable terrain types
|
||||
@ -829,11 +796,8 @@ routines.groupToPoint = function(gpData, point, form, heading, speed, useRoads)
|
||||
vars.disableRoads = useRoads
|
||||
vars.point = routines.utils.zoneToVec3( point )
|
||||
routines.groupToRandomPoint( vars )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
|
||||
routines.getLeadPos = function( group )
|
||||
if type( group ) == 'string' then -- group name
|
||||
group = Group.getByName( group )
|
||||
@ -934,7 +898,6 @@ routines.getBRString = function(vars)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Returns the Vec3 coordinates of the average position of the concentration of units most in the heading direction.
|
||||
--[[ vars for routines.getLeadingPos:
|
||||
vars.units - table of unit names
|
||||
@ -992,7 +955,6 @@ routines.getLeadingPos = function(vars)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--[[ vars for routines.getLeadingMGRSString:
|
||||
vars.units - table of unit names
|
||||
vars.heading - direction
|
||||
@ -1026,8 +988,6 @@ routines.getLeadingLLString = function(vars)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
--[[ vars for routines.getLeadingBRString:
|
||||
vars.units - table of unit names
|
||||
vars.heading - direction, number
|
||||
@ -1083,11 +1043,7 @@ routines.msgMGRS = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
end
|
||||
|
||||
--[[ vars for routines.msgLL
|
||||
@ -1114,15 +1070,10 @@ routines.msgLL = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
|
||||
end
|
||||
|
||||
|
||||
--[[
|
||||
vars.units- table of unit names (NOT unitNameTable- maybe this should change).
|
||||
vars.ref - vec3 ref point, maybe overload for vec2 as well?
|
||||
@ -1149,15 +1100,10 @@ routines.msgBR = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
-- basically, just sub-types of routines.msgBR... saves folks the work of getting the ref point.
|
||||
--[[
|
||||
@ -1228,14 +1174,9 @@ routines.msgLeadingMGRS = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
|
||||
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
end
|
||||
|
||||
--[[ vars for routines.msgLeadingLL:
|
||||
vars.units - table of unit names
|
||||
vars.heading - direction, number
|
||||
@ -1266,12 +1207,7 @@ routines.msgLeadingLL = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
end
|
||||
|
||||
--[[
|
||||
@ -1306,23 +1242,22 @@ routines.msgLeadingBR = function(vars)
|
||||
newText = text .. s
|
||||
end
|
||||
|
||||
routines.message.add{
|
||||
text = newText,
|
||||
displayTime = displayTime,
|
||||
msgFor = msgFor
|
||||
}
|
||||
routines.message.add { text = newText, displayTime = displayTime, msgFor = msgFor }
|
||||
end
|
||||
|
||||
|
||||
function spairs( t, order )
|
||||
-- collect the keys
|
||||
local keys = {}
|
||||
for k in pairs(t) do keys[#keys+1] = k end
|
||||
for k in pairs( t ) do
|
||||
keys[#keys + 1] = k
|
||||
end
|
||||
|
||||
-- if order function given, sort by it by passing the table and keys a, b,
|
||||
-- otherwise just sort the keys
|
||||
if order then
|
||||
table.sort(keys, function(a,b) return order(t, a, b) end)
|
||||
table.sort( keys, function( a, b )
|
||||
return order( t, a, b )
|
||||
end )
|
||||
else
|
||||
table.sort( keys )
|
||||
end
|
||||
@ -1337,7 +1272,6 @@ function spairs(t, order)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function routines.IsPartOfGroupInZones( CargoGroup, LandingZones )
|
||||
-- trace.f()
|
||||
|
||||
@ -1359,8 +1293,6 @@ function routines.IsPartOfGroupInZones( CargoGroup, LandingZones )
|
||||
return CurrentZoneID
|
||||
end
|
||||
|
||||
|
||||
|
||||
function routines.IsUnitInZones( TransportUnit, LandingZones )
|
||||
-- trace.f("", "routines.IsUnitInZones" )
|
||||
|
||||
@ -1441,7 +1373,6 @@ function routines.IsUnitNearZonesRadius( TransportUnit, LandingZones, ZoneRadius
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function routines.IsStaticInZones( TransportStatic, LandingZones )
|
||||
-- trace.f()
|
||||
|
||||
@ -1474,7 +1405,6 @@ function routines.IsStaticInZones( TransportStatic, LandingZones )
|
||||
return TransportZoneResult
|
||||
end
|
||||
|
||||
|
||||
function routines.IsUnitInRadius( CargoUnit, ReferencePosition, Radius )
|
||||
-- trace.f()
|
||||
|
||||
@ -1517,7 +1447,6 @@ function routines.IsPartOfGroupInRadius( CargoGroup, ReferencePosition, Radius )
|
||||
return Valid
|
||||
end
|
||||
|
||||
|
||||
function routines.ValidateString( Variable, VariableName, Valid )
|
||||
-- trace.f()
|
||||
|
||||
@ -1546,7 +1475,6 @@ function routines.ValidateNumber( Variable, VariableName, Valid )
|
||||
|
||||
-- trace.r( "", "", { Valid } )
|
||||
return Valid
|
||||
|
||||
end
|
||||
|
||||
function routines.ValidateGroup( Variable, VariableName, Valid )
|
||||
@ -1672,7 +1600,6 @@ end
|
||||
|
||||
routines.ground.patrolRoute = function( vars )
|
||||
|
||||
|
||||
local tempRoute = {}
|
||||
local useRoute = {}
|
||||
local gpData = vars.gpData
|
||||
@ -1698,7 +1625,6 @@ routines.ground.patrolRoute = function(vars)
|
||||
routeProvided = true
|
||||
end
|
||||
|
||||
|
||||
local overRideSpeed = vars.speed or 'default'
|
||||
local pType = vars.pType
|
||||
local offRoadForm = vars.offRoadForm or 'default'
|
||||
@ -1707,7 +1633,6 @@ routines.ground.patrolRoute = function(vars)
|
||||
if routeProvided == false and #tempRoute > 0 then
|
||||
local posStart = routines.getLeadPos( gpData )
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = routines.ground.buildWP( posStart, offRoadForm, overRideSpeed )
|
||||
for i = 1, #tempRoute do
|
||||
local tempForm = tempRoute[i].action
|
||||
@ -1729,7 +1654,6 @@ routines.ground.patrolRoute = function(vars)
|
||||
tempSpeed = overRideSpeed
|
||||
end
|
||||
|
||||
|
||||
useRoute[#useRoute + 1] = routines.ground.buildWP( tempRoute[i], tempForm, tempSpeed )
|
||||
end
|
||||
|
||||
@ -1751,24 +1675,10 @@ routines.ground.patrolRoute = function(vars)
|
||||
cTask3[#cTask3 + 1] = routines.utils.oneLineSerialize( newPatrol )
|
||||
cTask3[#cTask3 + 1] = ')'
|
||||
cTask3 = table.concat( cTask3 )
|
||||
local tempTask = {
|
||||
id = 'WrappedAction',
|
||||
params = {
|
||||
action = {
|
||||
id = 'Script',
|
||||
params = {
|
||||
command = cTask3,
|
||||
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
local tempTask = { id = 'WrappedAction', params = { action = { id = 'Script', params = { command = cTask3 } } } }
|
||||
|
||||
useRoute[#useRoute].task = tempTask
|
||||
routines.goRoute( gpData, useRoute )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
routines.ground.patrol = function( gpData, pType, form, speed )
|
||||
@ -1785,8 +1695,6 @@ routines.ground.patrol = function(gpData, pType, form, speed)
|
||||
vars.speed = speed
|
||||
|
||||
routines.ground.patrolRoute( vars )
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
function routines.GetUnitHeight( CheckUnit )
|
||||
@ -1803,11 +1711,8 @@ function routines.GetUnitHeight( CheckUnit )
|
||||
-- trace.f( "routines", "Unit Height = " .. UnitHeight - LandHeight )
|
||||
|
||||
return UnitHeight - LandHeight
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Su34Status = { status = {} }
|
||||
boardMsgRed = { statusMsg = "" }
|
||||
boardMsgAll = { timeMsg = "" }
|
||||
@ -1815,7 +1720,6 @@ SpawnSettings = {}
|
||||
Su34MenuPath = {}
|
||||
Su34Menus = 0
|
||||
|
||||
|
||||
function Su34AttackCarlVinson( groupName )
|
||||
-- trace.menu("", "Su34AttackCarlVinson")
|
||||
local groupSu34 = Group.getByName( groupName )
|
||||
@ -1982,7 +1886,6 @@ function Su34OverviewStatus()
|
||||
boardMsgRed.statusMsg = msg
|
||||
end
|
||||
|
||||
|
||||
function UpdateBoardMsg()
|
||||
-- trace.f()
|
||||
Su34OverviewStatus()
|
||||
@ -2007,63 +1910,22 @@ function Su34Menu(groupName)
|
||||
-- env.info(( 'Su34Menu(' .. groupName .. ')' ))
|
||||
local groupSu34 = Group.getByName( groupName )
|
||||
|
||||
if Su34Status.status[groupName] == 1 or
|
||||
Su34Status.status[groupName] == 2 or
|
||||
Su34Status.status[groupName] == 3 or
|
||||
Su34Status.status[groupName] == 4 or
|
||||
Su34Status.status[groupName] == 5 then
|
||||
if Su34Status.status[groupName] == 1 or Su34Status.status[groupName] == 2 or Su34Status.status[groupName] == 3 or Su34Status.status[groupName] == 4 or Su34Status.status[groupName] == 5 then
|
||||
if Su34MenuPath[groupName] == nil then
|
||||
if planeMenuPath == nil then
|
||||
planeMenuPath = missionCommands.addSubMenuForCoalition(
|
||||
coalition.side.RED,
|
||||
"SU-34 anti-ship flights",
|
||||
nil
|
||||
)
|
||||
planeMenuPath = missionCommands.addSubMenuForCoalition( coalition.side.RED, "SU-34 anti-ship flights", nil )
|
||||
end
|
||||
Su34MenuPath[groupName] = missionCommands.addSubMenuForCoalition(
|
||||
coalition.side.RED,
|
||||
"Flight " .. groupName,
|
||||
planeMenuPath
|
||||
)
|
||||
Su34MenuPath[groupName] = missionCommands.addSubMenuForCoalition( coalition.side.RED, "Flight " .. groupName, planeMenuPath )
|
||||
|
||||
missionCommands.addCommandForCoalition(
|
||||
coalition.side.RED,
|
||||
"Attack carrier Carl Vinson",
|
||||
Su34MenuPath[groupName],
|
||||
Su34AttackCarlVinson,
|
||||
groupName
|
||||
)
|
||||
missionCommands.addCommandForCoalition( coalition.side.RED, "Attack carrier Carl Vinson", Su34MenuPath[groupName], Su34AttackCarlVinson, groupName )
|
||||
|
||||
missionCommands.addCommandForCoalition(
|
||||
coalition.side.RED,
|
||||
"Attack ships in the west",
|
||||
Su34MenuPath[groupName],
|
||||
Su34AttackWest,
|
||||
groupName
|
||||
)
|
||||
missionCommands.addCommandForCoalition( coalition.side.RED, "Attack ships in the west", Su34MenuPath[groupName], Su34AttackWest, groupName )
|
||||
|
||||
missionCommands.addCommandForCoalition(
|
||||
coalition.side.RED,
|
||||
"Attack ships in the north",
|
||||
Su34MenuPath[groupName],
|
||||
Su34AttackNorth,
|
||||
groupName
|
||||
)
|
||||
missionCommands.addCommandForCoalition( coalition.side.RED, "Attack ships in the north", Su34MenuPath[groupName], Su34AttackNorth, groupName )
|
||||
|
||||
missionCommands.addCommandForCoalition(
|
||||
coalition.side.RED,
|
||||
"Hold position and await instructions",
|
||||
Su34MenuPath[groupName],
|
||||
Su34Orbit,
|
||||
groupName
|
||||
)
|
||||
missionCommands.addCommandForCoalition( coalition.side.RED, "Hold position and await instructions", Su34MenuPath[groupName], Su34Orbit, groupName )
|
||||
|
||||
missionCommands.addCommandForCoalition(
|
||||
coalition.side.RED,
|
||||
"Report status",
|
||||
Su34MenuPath[groupName],
|
||||
Su34OverviewStatus
|
||||
)
|
||||
missionCommands.addCommandForCoalition( coalition.side.RED, "Report status", Su34MenuPath[groupName], Su34OverviewStatus )
|
||||
end
|
||||
else
|
||||
if Su34MenuPath[groupName] then
|
||||
@ -2207,32 +2069,23 @@ function EscortCarrier ( CarrierGroup, EscortPrefix, EscortLastWayPoint, EscortE
|
||||
EscortMission.units[u].unitId = nil
|
||||
end
|
||||
|
||||
|
||||
EscortMission.route.points[1].task = { id = "ComboTask",
|
||||
params =
|
||||
{
|
||||
tasks =
|
||||
{
|
||||
[1] =
|
||||
{
|
||||
EscortMission.route.points[1].task = {
|
||||
id = "ComboTask",
|
||||
params = {
|
||||
tasks = {
|
||||
[1] = {
|
||||
enabled = true,
|
||||
auto = false,
|
||||
id = "Escort",
|
||||
number = 1,
|
||||
params =
|
||||
{
|
||||
params = {
|
||||
lastWptIndexFlagChangedManually = false,
|
||||
groupId = CarrierGroup:getID(),
|
||||
lastWptIndex = nil,
|
||||
lastWptIndexFlag = false,
|
||||
engagementDistMax = EscortEngagementDistanceMax,
|
||||
targetTypes = EscortTargetTypes,
|
||||
pos =
|
||||
{
|
||||
y = 20,
|
||||
x = 20,
|
||||
z = 0,
|
||||
} -- end of ["pos"]
|
||||
pos = { y = 20, x = 20, z = 0 } -- end of ["pos"]
|
||||
} -- end of ["params"]
|
||||
} -- end of [1]
|
||||
} -- end of ["tasks"]
|
||||
@ -2325,7 +2178,6 @@ function getCarrierHeight( CarrierGroup )
|
||||
else
|
||||
return 999999
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function GetUnitHeight( CheckUnit )
|
||||
@ -2340,16 +2192,13 @@ function GetUnitHeight( CheckUnit )
|
||||
-- env.info(( 'CarrierHeight: LandHeight = ' .. LandHeight .. ' CarrierHeight = ' .. CarrierHeight ))
|
||||
|
||||
return UnitHeight - LandHeight
|
||||
|
||||
end
|
||||
|
||||
|
||||
_MusicTable = {}
|
||||
_MusicTable.Files = {}
|
||||
_MusicTable.Queue = {}
|
||||
_MusicTable.FileCnt = 0
|
||||
|
||||
|
||||
function MusicRegister( SndRef, SndFile, SndTime )
|
||||
-- trace.f()
|
||||
|
||||
@ -2357,7 +2206,6 @@ function MusicRegister( SndRef, SndFile, SndTime )
|
||||
env.info( ('MusicRegister: SndFile = ' .. SndFile) )
|
||||
env.info( ('MusicRegister: SndTime = ' .. SndTime) )
|
||||
|
||||
|
||||
_MusicTable.FileCnt = _MusicTable.FileCnt + 1
|
||||
|
||||
_MusicTable.Files[_MusicTable.FileCnt] = {}
|
||||
@ -2368,7 +2216,6 @@ function MusicRegister( SndRef, SndFile, SndTime )
|
||||
if not _MusicTable.Function then
|
||||
_MusicTable.Function = routines.scheduleFunction( MusicScheduler, {}, timer.getTime() + 10, 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function MusicToPlayer( SndRef, PlayerName, SndContinue )
|
||||
@ -2391,7 +2238,6 @@ function MusicToPlayer( SndRef, PlayerName, SndContinue )
|
||||
end
|
||||
|
||||
-- env.info(( 'MusicToPlayer: end' ))
|
||||
|
||||
end
|
||||
|
||||
function MusicToGroup( SndRef, SndGroup, SndContinue )
|
||||
@ -2494,9 +2340,6 @@ function MusicScheduler()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
env.info( ('Init: Scripts Loaded v1.1') )
|
||||
|
||||
|
||||
@ -1,21 +1,18 @@
|
||||
--- **Utilities** DCS Simple Text-To-Speech (STTS).
|
||||
--
|
||||
--
|
||||
--
|
||||
-- @module Utils.STTS
|
||||
-- @image MOOSE.JPG
|
||||
|
||||
--- [DCS Enum world](https://wiki.hoggitworld.com/view/DCS_enum_world)
|
||||
-- @type STTS
|
||||
-- @field #string DIRECTORY Path of the SRS directory.
|
||||
|
||||
--- Simple Text-To-Speech
|
||||
--
|
||||
-- Version 0.4 - Compatible with SRS version 1.9.6.0+
|
||||
--
|
||||
-- # DCS Modification Required
|
||||
--
|
||||
-- You will need to edit MissionScripting.lua in DCS World/Scripts/MissionScripting.lua and remove the sanitisation.
|
||||
-- You will need to edit MissionScripting.lua in DCS World/Scripts/MissionScripting.lua and remove the sanitization.
|
||||
-- To do this remove all the code below the comment - the line starts "local function sanitizeModule(name)"
|
||||
-- Do this without DCS running to allow mission scripts to use os functions.
|
||||
--
|
||||
@ -23,7 +20,7 @@
|
||||
--
|
||||
-- # USAGE:
|
||||
--
|
||||
-- Add this script into the mission as a DO SCRIPT or DO SCRIPT FROM FILE to initialise it
|
||||
-- Add this script into the mission as a DO SCRIPT or DO SCRIPT FROM FILE to initialize it
|
||||
-- Make sure to edit the STTS.SRS_PORT and STTS.DIRECTORY to the correct values before adding to the mission.
|
||||
-- Then its as simple as calling the correct function in LUA as a DO SCRIPT or in your own scripts.
|
||||
--
|
||||
@ -80,7 +77,7 @@ STTS={
|
||||
DIRECTORY = "",
|
||||
SRS_PORT = 5002,
|
||||
GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json",
|
||||
EXECUTABLE="DCS-SR-ExternalAudio.exe",
|
||||
EXECUTABLE = "DCS-SR-ExternalAudio.exe"
|
||||
}
|
||||
|
||||
--- FULL Path to the FOLDER containing DCS-SR-ExternalAudio.exe - EDIT TO CORRECT FOLDER
|
||||
@ -95,7 +92,6 @@ STTS.GOOGLE_CREDENTIALS = "C:\\Users\\Ciaran\\Downloads\\googletts.json"
|
||||
--- DONT CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
STTS.EXECUTABLE = "DCS-SR-ExternalAudio.exe"
|
||||
|
||||
|
||||
--- Function for UUID.
|
||||
function STTS.uuid()
|
||||
local random = math.random
|
||||
@ -112,7 +108,11 @@ end
|
||||
function STTS.round( x, n )
|
||||
n = math.pow( 10, n or 0 )
|
||||
x = x * n
|
||||
if x >= 0 then x = math.floor(x + 0.5) else x = math.ceil(x - 0.5) end
|
||||
if x >= 0 then
|
||||
x = math.floor( x + 0.5 )
|
||||
else
|
||||
x = math.ceil( x - 0.5 )
|
||||
end
|
||||
return x / n
|
||||
end
|
||||
|
||||
@ -170,7 +170,6 @@ function STTS.TextToSpeech(message, freqs, modulations, volume, name, coalition,
|
||||
volume = 1
|
||||
speed = 1
|
||||
|
||||
|
||||
message = message:gsub( "\"", "\\\"" )
|
||||
|
||||
local cmd = string.format( "start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", STTS.DIRECTORY, STTS.EXECUTABLE, freqs or "305", modulations or "AM", coalition, STTS.SRS_PORT, name )
|
||||
@ -237,8 +236,7 @@ end
|
||||
-- @param #string volume Volume, e.g. "0.5".
|
||||
function STTS.PlayMP3( pathToMP3, freqs, modulations, volume, name, coalition, point )
|
||||
|
||||
local cmd = string.format("start \"\" /d \"%s\" /b /min \"%s\" -i \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -v %s -h",
|
||||
STTS.DIRECTORY, STTS.EXECUTABLE, pathToMP3, freqs or "305", modulations or "AM", coalition or "0", STTS.SRS_PORT, name or "ROBOT", volume or "1")
|
||||
local cmd = string.format( "start \"\" /d \"%s\" /b /min \"%s\" -i \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -v %s -h", STTS.DIRECTORY, STTS.EXECUTABLE, pathToMP3, freqs or "305", modulations or "AM", coalition or "0", STTS.SRS_PORT, name or "ROBOT", volume or "1" )
|
||||
|
||||
if point and type( point ) == "table" and point.x then
|
||||
local lat, lon, alt = coord.LOtoLL( point )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user