@jtff/miztemplate-lib 3.1.9 → 3.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,9 +8,19 @@
8
8
  --
9
9
  env.info('JTFF-SHAREDLIB: shared library loading...')
10
10
 
11
- DEBUG_MSG = false
12
- DEBUG_SC_MSG = false
13
- DEBUG_DETECT_MSG = false
11
+ log_modes = {
12
+ { name = "trace", color = "\27[34m", },
13
+ { name = "debug", color = "\27[36m", },
14
+ { name = "info", color = "\27[32m", },
15
+ { name = "warn", color = "\27[33m", },
16
+ { name = "error", color = "\27[31m", },
17
+ { name = "fatal", color = "\27[35m", },
18
+ }
19
+ log_levels = {}
20
+ for i, v in ipairs(log_modes) do
21
+ log_levels[v.name] = i
22
+ end
23
+ JTFF_LOGLEVEL = 'info'
14
24
 
15
25
  use_jtff_sound_mod = false
16
26
 
@@ -19,6 +29,9 @@ spawnStandardDelay = 15
19
29
  sead = SEAD:New({})
20
30
  map_marker = {}
21
31
 
32
+ HoundBlue = HoundElint:create(coalition.side.BLUE)
33
+ HoundRed = HoundElint:create(coalition.side.RED)
34
+
22
35
  AAMAxRange = {
23
36
  MAX_RANGE = 0,
24
37
  NEZ_RANGE = 1,
@@ -27,28 +40,21 @@ AAMAxRange = {
27
40
  RANDOM_RANGE = 4,
28
41
  }
29
42
 
30
-
31
- function debug_msg(message)
32
- if DEBUG_MSG then
33
- env.info(string.format("[DEBUG] %s", message))
34
- end
35
- end
36
-
37
- function debug_detection_msg(message)
38
- if DEBUG_DETECT_MSG then
39
- env.info(string.format("[DEBUG DETECTION] %s", message))
40
- end
41
- end
42
-
43
- function debug_scheduler_msg(message)
44
- if DEBUG_SC_MSG then
45
- env.info(string.format("[DEBUG SCHEDULER] %s", message))
43
+ jtff_log = {}
44
+ for index, mode in ipairs(log_modes) do
45
+ local nameupper = mode.name:upper()
46
+ jtff_log[mode.name] = function(message, category)
47
+ -- Return early if we're below the log level
48
+ if index < log_levels[JTFF_LOGLEVEL] then
49
+ return
50
+ end
51
+ env.info(string.format("[JTFF-%s]--%s-- %s", mode.name, category, message))
46
52
  end
47
53
  end
48
54
 
49
55
  function switchGroupImmortalStatus(group)
50
56
  status = not BASE:GetState(group, "isImmortal")
51
- debug_msg(string.format("switch group %s to immortal status %s", group:GetName(), tostring(status)))
57
+ jtff_log.info(string.format("switch group %s to immortal status %s", group:GetName(), tostring(status)), "GENERAL")
52
58
  group:SetCommandImmortal(status)
53
59
  BASE:SetState(group, "isImmortal", status)
54
60
  MESSAGE:NewType("Immortal status of your group : " .. tostring(status) , MESSAGE.Type.Update):ToGroup(group)
@@ -114,33 +120,33 @@ function tankerStatusMessage(tanker, PlayerUnit, PlayerGroup)
114
120
  local timeLeftString = "Time left : "
115
121
  local groupName = tanker:GetName()
116
122
  for index, value in pairs(tankersArray) do
117
- debug_msg(string.format("%s spawned at %i", value.tanker.GroupName, value.spawnAbsTime))
123
+ jtff_log.debug(string.format("%s spawned at %i", value.tanker.GroupName, value.spawnAbsTime),"TANKER")
118
124
  if (string.find(groupName, value.tanker.GroupName, 1, true) ~= nil) then
119
125
  timeInTheAir = timer.getAbsTime() - value.spawnAbsTime
120
126
  timeLeftInTheAir = value.customconfig.missionmaxduration * 60 - timeInTheAir
121
127
  if (UTILS.SecondsToClock(timeLeftInTheAir, true) ~= nil) then
122
128
  timeLeftString = timeLeftString .. UTILS.SecondsToClock(timeLeftInTheAir, true)
123
129
  end
124
- debug_msg(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
125
- value.tanker.GroupName, groupName, timeInTheAir, timeLeftInTheAir))
130
+ jtff_log.debug(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
131
+ value.tanker.GroupName, groupName, timeInTheAir, timeLeftInTheAir), "TANKER")
126
132
  else
127
- debug_msg(string.format("%s not found in %s", value.tanker.GroupName, groupName))
133
+ jtff_log.warn(string.format("%s not found in %s", value.tanker.GroupName, groupName),"TANKER")
128
134
  end
129
135
  end
130
136
 
131
137
  for index, value in pairs(tankersOnDemandArray) do
132
138
  if( value ~= nil) then
133
- debug_msg(string.format("%s spawned in tankersOnDemandArray", value:GetName()))
139
+ jtff_log.info(string.format("%s spawned in tankersOnDemandArray", value:GetName()),"TANKER")
134
140
  if (string.find(groupName, value:GetName(), 1, true) ~= nil) then
135
141
  timeInTheAir = timer.getAbsTime() - value.spawnAbsTime
136
142
  timeLeftInTheAir = value.missionmaxduration * 60 - timeInTheAir
137
143
  if (UTILS.SecondsToClock(timeLeftInTheAir, true) ~= nil) then
138
144
  timeLeftString = timeLeftString .. UTILS.SecondsToClock(timeLeftInTheAir, true)
139
145
  end
140
- debug_msg(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
141
- value:GetName(), groupName, timeInTheAir, timeLeftInTheAir))
146
+ jtff_log.debug(string.format("%s found in %s, time in the air : %i sec, time left %i sec",
147
+ value:GetName(), groupName, timeInTheAir, timeLeftInTheAir),"TANKER")
142
148
  else
143
- debug_msg(string.format("%s not found in %s", value:GetName(), groupName))
149
+ jtff_log.warn(string.format("%s not found in %s", value:GetName(), groupName),"TANKER")
144
150
  end
145
151
  end
146
152
  end
@@ -261,7 +267,7 @@ function taskTankerEscort(param)
261
267
  )
262
268
  }
263
269
  )
264
- env.info('Escort group spawned : '.. EscortGroup.GroupName..'. Escorting '..recoveryTankerObject.tanker.GroupName)
270
+ jtff_log.info('Escort group spawned : '.. EscortGroup.GroupName..'. Escorting '..recoveryTankerObject.tanker.GroupName,"TANKER")
265
271
  end
266
272
 
267
273
  function taskGroupEscort(param)
@@ -301,7 +307,7 @@ function taskGroupEscort(param)
301
307
  )
302
308
  }
303
309
  )
304
- env.info('Escort group spawned : '.. EscortingGroup.GroupName..'. Escorting '.. GroupToEscortObject.GroupName)
310
+ jtff_log.info('Escort group spawned : '.. EscortingGroup.GroupName..'. Escorting '.. GroupToEscortObject.GroupName,"GENERAL")
305
311
  end
306
312
 
307
313
  function spawnRecoveryTankerEscort(escortSpawnObject,customconfig)
@@ -342,7 +348,7 @@ function getMaxThreatUnit(setUnits)
342
348
  setUnits:ForEachUnitPerThreatLevel(10, 0, function(unit)
343
349
  setUnitsSorted:AddUnit(unit)
344
350
  end)
345
- debug_msg(string.format("Max priority unit : %s", setUnitsSorted:GetFirst():GetName()))
351
+ jtff_log.debug(string.format("Max priority unit : %s", setUnitsSorted:GetFirst():GetName()), "GENERAL")
346
352
  return setUnitsSorted:GetFirst()
347
353
  end
348
354
 
@@ -350,7 +356,7 @@ function destroyGroup(group_name)
350
356
  local set_group_alive = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
351
357
  set_group_alive:ForEachGroupAlive(
352
358
  function(group_alive)
353
- debug_msg(string.format("Group %s just removed", group_alive:GetName()))
359
+ jtff_log.info(string.format("Group %s just removed", group_alive:GetName()),"GENERAL")
354
360
  if (map_marker[group_alive:GetName()]) then
355
361
  COORDINATE:RemoveMark(map_marker[group_alive:GetName()])
356
362
  end
@@ -366,18 +372,18 @@ function destroyStatic(staticToDelete, subRangeName, index)
366
372
  end
367
373
  local staticUnitToDelete = STATIC:FindByName(staticNameToDelete, false)
368
374
  if (staticUnitToDelete ~= nil) then
369
- debug_msg(string.format("Delete static %s", staticUnitToDelete:GetDCSObject():getName()))
375
+ jtff_log.info(string.format("Delete static %s", staticUnitToDelete:GetDCSObject():getName()),"GENERAL")
370
376
  staticUnitToDelete:Destroy()
371
377
  end
372
378
  elseif (staticToDelete.type ~= nil and staticToDelete.category ~= nil and index ~= nil) then
373
379
  local staticNameToDelete = string.format("%s_%s_%i", subRangeName, staticToDelete.type, index)
374
380
  local staticUnitToDelete = STATIC:FindByName(staticNameToDelete, false)
375
381
  if (staticUnitToDelete ~= nil) then
376
- debug_msg(string.format("Delete Static %s", staticUnitToDelete:GetDCSObject():getName()))
382
+ jtff_log.info(string.format("Delete Static %s", staticUnitToDelete:GetDCSObject():getName()),"GENERAL")
377
383
  staticUnitToDelete:Destroy()
378
384
  end
379
385
  else
380
- debug_msg(string.format("Static to delete has no name or type!"))
386
+ jtff_log.error(string.format("Static to delete has no name or type!"), "GENERAL")
381
387
  end
382
388
  end
383
389
 
@@ -408,7 +414,7 @@ function deleteSubRangeUnits(param)
408
414
  if (staticsToDelete ~= nil)then
409
415
  destroyStatics(staticsToDelete, subRangeName)
410
416
  else
411
- debug_msg(string.format("No static in %s", subRangeName))
417
+ jtff_log.warn(string.format("No static in %s", subRangeName), "RANGE")
412
418
  end
413
419
 
414
420
  MESSAGE:NewType(string.format("Remove the site : %s-%s", rangeConfig.name, subRangeConfig.name),
@@ -466,7 +472,7 @@ function setROE(param)
466
472
  local group_name = string.format("%s", groupsToSpawn[groupIndex])
467
473
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
468
474
  dcs_groups:ForEachGroupAlive(function(group_alive)
469
- debug_msg(string.format("SET ROE of group %s at %i", group_alive:GetName(), ROEvalue))
475
+ jtff_log.info(string.format("SET ROE of group %s at %i", group_alive:GetName(), ROEvalue), "GENERAL")
470
476
  if (ROEvalue ~= ENUMS.ROE.WeaponHold) then
471
477
  group_alive:SetAIOn()
472
478
  end
@@ -484,13 +490,13 @@ function setAlarmState(param)
484
490
  dcs_groups:ForEachGroupAlive(function(group_alive)
485
491
  group_alive:SetAIOn()
486
492
  if AlarmStateValue == ENUMS.AlarmState.Auto then
487
- debug_msg(string.format("SET Alarm State of group %s at AUTO", group_alive:GetName()))
493
+ jtff_log.info(string.format("SET Alarm State of group %s at AUTO", group_alive:GetName()),"GENERAL")
488
494
  group_alive:OptionAlarmStateAuto()
489
495
  elseif AlarmStateValue == ENUMS.AlarmState.Green then
490
- debug_msg(string.format("SET Alarm State of group %s at Green", group_alive:GetName()))
496
+ jtff_log.info(string.format("SET Alarm State of group %s at Green", group_alive:GetName()),"GENERAL")
491
497
  group_alive:OptionAlarmStateGreen()
492
498
  elseif AlarmStateValue == ENUMS.AlarmState.Red then
493
- debug_msg(string.format("SET Alarm State of group %s at Red", group_alive:GetName()))
499
+ jtff_log.info(string.format("SET Alarm State of group %s at Red", group_alive:GetName()),"GENERAL")
494
500
  group_alive:OptionAlarmStateRed()
495
501
  end
496
502
  end)
@@ -504,7 +510,7 @@ function setEngageAirWeapons(param)
504
510
  local group_name = string.format("%s", groupsToSpawn[groupIndex])
505
511
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
506
512
  dcs_groups:ForEachGroupAlive(function(group_alive)
507
- debug_msg(string.format("SET Engage Air Weapons of group %s at %s", group_alive:GetName(), tostring(value)))
513
+ jtff_log.info(string.format("SET Engage Air Weapons of group %s at %s", group_alive:GetName(), tostring(value)),"GENERAL")
508
514
  if (value) then
509
515
  group_alive:SetAIOn()
510
516
  end
@@ -520,7 +526,7 @@ function smokeOnSubRange(param)
520
526
  local group_name = string.format("%s", groupsToSpawn[groupIndex])
521
527
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
522
528
  dcs_groups:ForEachGroupAlive(function(group_alive)
523
- debug_msg(string.format("Smoke on group %s", group_alive:GetName()))
529
+ jtff_log.info(string.format("Smoke on group %s", group_alive:GetName()),"GENERAL")
524
530
  local list_units = group_alive:GetUnits()
525
531
  local set_units_red = SET_UNIT:New()
526
532
  local set_units_blue = SET_UNIT:New()
@@ -553,35 +559,35 @@ function giveToClientGroupCoordinates(param)
553
559
  local groupsToSpawn = param[1]
554
560
  for i = 1, #groupsToSpawn do
555
561
  local group_name = string.format("%s", groupsToSpawn[i])
556
- debug_msg(string.format("Coordinates of all groups with name prefix %s", group_name))
562
+ jtff_log.debug(string.format("Coordinates of all groups with name prefix %s", group_name),"GENERAL")
557
563
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
558
564
  Set_CLIENT:ForEachClient(function(client)
559
565
  if (client:IsActive()) then
560
- debug_msg(string.format("For Client %s ", client:GetName()))
566
+ jtff_log.debug(string.format("For Client %s ", client:GetName()),"GENERAL")
561
567
  local coordinate_txt = ""
562
568
  dcs_groups:ForEachGroupAlive(function(group_alive)
563
- debug_msg(string.format("Coordinates of the group %s", group_alive:GetName()))
569
+ jtff_log.debug(string.format("Coordinates of the group %s", group_alive:GetName()),"GENERAL")
564
570
  local coordinate = group_alive:GetCoordinate()
565
571
  local setting = _DATABASE:GetPlayerSettings(client:GetPlayerName())
566
572
  local coordinate_string = ""
567
573
  if (setting:IsA2G_LL_DDM()) then
568
574
  coordinate_string = coordinate:ToStringLLDDM(setting)
569
- debug_msg(string.format("%s IsA2G_LL_DDM", client:GetName()))
575
+ jtff_log.debug(string.format("%s IsA2G_LL_DDM", client:GetName()),"GENERAL")
570
576
  elseif (setting:IsA2G_MGRS()) then
571
577
  coordinate_string = coordinate:ToStringMGRS(setting)
572
- debug_msg(string.format("%s IsA2G_MGRS", client:GetName()))
578
+ jtff_log.debug(string.format("%s IsA2G_MGRS", client:GetName()),"GENERAL")
573
579
  elseif (setting:IsA2G_LL_DMS()) then
574
580
  coordinate_string = coordinate:ToStringLLDMS(setting)
575
- debug_msg(string.format("%s IsA2G_LL_DMS", client:GetName()))
581
+ jtff_log.debug(string.format("%s IsA2G_LL_DMS", client:GetName()),"GENERAL")
576
582
  elseif (setting:IsA2G_BR()) then
577
583
  coordinate_string = coordinate:ToStringBR(client:GetCoordinate(), setting)
578
- debug_msg(string.format("%s IsA2G_BR", client:GetName()))
584
+ jtff_log.debug(string.format("%s IsA2G_BR", client:GetName()),"GENERAL")
579
585
  end
580
- debug_msg(string.format("coordinate_txt [%s] : %s", group_alive:GetName(), coordinate_string))
586
+ jtff_log.debug(string.format("coordinate_txt [%s] : %s", group_alive:GetName(), coordinate_string),"GENERAL")
581
587
  coordinate_txt = string.format("%s[%s] : %s\n", coordinate_txt, group_alive:GetName(),
582
588
  coordinate_string)
583
589
  end)
584
- debug_msg(string.format("Message to Client %s : %s", client:GetName(), coordinate_txt))
590
+ jtff_log.debug(string.format("Message to Client %s : %s", client:GetName(), coordinate_txt),"GENERAL")
585
591
  MESSAGE:NewType(coordinate_txt, MESSAGE.Type.Detailed):ToClient(client)
586
592
  end
587
593
  end)
@@ -592,13 +598,13 @@ function giveListOfGroupsAliveInRange(param)
592
598
  local groupsToSpawn = param[1]
593
599
  local rangeConfig = param[2]
594
600
  local subRangeConfig = param[3]
595
- debug_msg(string.format("List of groups in range %s-%s", rangeConfig.name, subRangeConfig.name))
601
+ jtff_log.debug(string.format("List of groups in range %s-%s", rangeConfig.name, subRangeConfig.name),"RANGE")
596
602
  local message = string.format("Targets groups in Range %s-%s :", rangeConfig.name, subRangeConfig.name)
597
603
  for i = 1, #groupsToSpawn do
598
604
  local group_name = string.format("%s", groupsToSpawn[i])
599
605
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
600
606
  dcs_groups:ForEachGroupAlive(function(group_alive)
601
- debug_msg(string.format("group %s", group_alive:GetName()))
607
+ jtff_log.debug(string.format("group %s", group_alive:GetName()),"RANGE")
602
608
  message = string.format("%s %s | ", message, group_alive:GetName());
603
609
  end)
604
610
  end
@@ -615,10 +621,10 @@ function giveListOfUnitsAliveInGroup(param)
615
621
  local number_to_display = param[3]
616
622
  for i = 1, #groupsToSpawn do
617
623
  local group_name = string.format("%s", groupsToSpawn[i])
618
- debug_msg(string.format("List of units of all groups with name prefix %s", group_name))
624
+ jtff_log.debug(string.format("List of units of all groups with name prefix %s", group_name),"GENERAL")
619
625
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
620
626
  dcs_groups:ForEachGroupAlive(function(group_alive)
621
- debug_msg(string.format("List of units of the group %s", group_alive:GetName()))
627
+ jtff_log.debug(string.format("List of units of the group %s", group_alive:GetName()),"GENERAL")
622
628
  local info_unit_header = string.format("Units list of the group [%s]:", group_name)
623
629
  Set_CLIENT:ForEachClient(function(client)
624
630
  if (client:IsActive()) then
@@ -631,7 +637,7 @@ function giveListOfUnitsAliveInGroup(param)
631
637
  local unit_tmp = list_units[index]
632
638
  if (unit_tmp:IsAlive() and unit_tmp:GetCoalition() ~= side) then
633
639
  set_units:AddUnit(unit_tmp)
634
- debug_msg(string.format("Type : %s", unit_tmp:GetTypeName()))
640
+ jtff_log.debug(string.format("Type : %s", unit_tmp:GetTypeName()),"GENERAL")
635
641
  end
636
642
  end
637
643
  local increment = 0;
@@ -682,10 +688,10 @@ function markGroupOnMap(param)
682
688
  local side = param[2]
683
689
  for i = 2, #groupsToSpawn do
684
690
  local group_name = string.format("%s", groupsToSpawn[i])
685
- debug_msg(string.format("Mark on map all groups with name prefix %s", group_name))
691
+ jtff_log.info(string.format("Mark on map all groups with name prefix %s", group_name),"MARK")
686
692
  local dcs_groups = SET_GROUP:New():FilterPrefixes(group_name):FilterOnce()
687
693
  dcs_groups:ForEachGroupAlive(function(group_alive)
688
- debug_msg(string.format("Mark on map the group %s", group_alive:GetName()))
694
+ jtff_log.info(string.format("Mark on map the group %s", group_alive:GetName()),"MARK")
689
695
  local coordinate = group_alive:GetCoordinate()
690
696
  map_marker[group_alive:GetName()] = coordinate:MarkToCoalition(group_alive:GetName(), side)
691
697
  end)
@@ -815,7 +821,7 @@ function SpawnRanges(param)
815
821
  local activateAI = subRangeConfig.AI
816
822
  local redAlert = subRangeConfig.redAlert
817
823
 
818
- debug_msg(string.format("SpawnRanges : Range %s - Targets %s", rangeName, subRangeName))
824
+ jtff_log.info(string.format("SpawnRanges : Range %s - Targets %s", rangeName, subRangeName),"RANGE")
819
825
  if (staticsToSpawn ~= nil)then
820
826
  for index, staticToSpawn in ipairs(staticsToSpawn) do
821
827
  local spawnStatic = nil
@@ -836,7 +842,7 @@ function SpawnRanges(param)
836
842
  local heading = staticToSpawn.heading
837
843
  local name = string.format("%s_%s_%i", subRangeName, staticNameToSpawn,index)
838
844
  local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name )
839
- debug_msg(string.format("Static to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()))
845
+ jtff_log.info(string.format("Static to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"RANGE")
840
846
  elseif (staticToSpawn.type ~= nil and staticToSpawn.category ~= nil) then
841
847
  local staticTypeToSpawn = string.format("%s", staticToSpawn.type)
842
848
  local staticCategoryToSpawn = string.format("%s", staticToSpawn.category)
@@ -855,20 +861,20 @@ function SpawnRanges(param)
855
861
  local heading = staticToSpawn.heading
856
862
  local name = string.format("%s_%s_%i", subRangeName, staticTypeToSpawn, index)
857
863
  local static = spawnStatic:SpawnFromPointVec2( POINT_VEC2:New( x, y ), heading, name )
858
- debug_msg(string.format("Static type to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()))
864
+ jtff_log.info(string.format("Static type to spawn %s at %i,%i -> %s", static:GetDCSObject():getTypeName(), x, y, static:GetDCSObject():getName()),"RANGE")
859
865
  else
860
- debug_msg(string.format("Static to spawn has no name or type!"))
866
+ jtff_log.warn(string.format("Static to spawn has no name or type!"),"RANGE")
861
867
  end
862
868
  end
863
869
  else
864
- debug_msg(string.format("No static in %s", subRangeName))
870
+ jtff_log.warn(string.format("No static in %s", subRangeName),"RANGE")
865
871
  end
866
872
 
867
873
  for i = 1, #groupsToSpawn do
868
874
  local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
869
875
  if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
870
876
  local spawnGroup = SPAWN:New(groupNameToSpawn)
871
- debug_msg(string.format("SPAWN %s", groupNameToSpawn))
877
+ jtff_log.info(string.format("SPAWN %s", groupNameToSpawn), "RANGE")
872
878
  local groupSpawning
873
879
  if (subRangeConfig.spawnZone) then
874
880
  groupSpawning = spawnGroup:SpawnInZone(ZONE:New(subRangeConfig.spawnZone),true)
@@ -897,10 +903,10 @@ function SpawnRanges(param)
897
903
  end
898
904
  if (string.find(groupNameToSpawn, "SAM") ~= nil) then
899
905
  sead:UpdateSet(groupNameToSpawn)
900
- debug_msg(string.format("SEAD for %s", groupNameToSpawn))
906
+ jtff_log.info(string.format("SEAD for %s", groupNameToSpawn),"RANGE")
901
907
  end
902
908
  else
903
- debug_msg(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn))
909
+ jtff_log.error(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
904
910
  end
905
911
  end
906
912
 
@@ -956,12 +962,12 @@ function SpawnFacRanges(param)
956
962
  local groupsToSpawn = facSubRangeConfig.groupsToSpawn
957
963
  local staticsToSpawn = facSubRangeConfig.staticsToSpawn
958
964
 
959
- debug_msg(string.format("SpawnFacRanges : %s-%s", facRangeName, facSubRangeName))
965
+ jtff_log.info(string.format("SpawnFacRanges : %s-%s", facRangeName, facSubRangeName),"RANGE")
960
966
  for i = 1, #groupsToSpawn do
961
967
  local groupNameToSpawn = string.format("%s", groupsToSpawn[i])
962
968
  if (GROUP:FindByName(groupNameToSpawn) ~= nil) then
963
969
  local spawnGroup = SPAWN:New(groupNameToSpawn)
964
- debug_msg(string.format("SPAWN %s", groupNameToSpawn))
970
+ jtff_log.info(string.format("SPAWN %s", groupNameToSpawn),"RANGE")
965
971
  local groupSpawning
966
972
  if (facSubRangeConfig.spawnZone) then
967
973
  groupSpawning = spawnGroup:SpawnInZone(ZONE:New(facSubRangeConfig.spawnZone),true)
@@ -970,7 +976,7 @@ function SpawnFacRanges(param)
970
976
  end
971
977
  groupSpawning:SetCommandInvisible(true)
972
978
  else
973
- debug_msg(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn))
979
+ jtff_log.warn(string.format("GROUP to spawn %s not found in mission", groupNameToSpawn),"RANGE")
974
980
  end
975
981
  end
976
982
 
@@ -11,7 +11,7 @@ function Set_CLIENT:OnEventPlayerEnterAircraft(EventData)
11
11
  clientSetting:SetImperial()
12
12
  clientSetting:SetA2G_MGRS()
13
13
  clientSetting:SetMenutextShort(true)
14
- debug_msg(string.format("Add Tanker Menu for group [%s], player name [%s]",EventData.IniGroupName , EventData.IniPlayerName))
14
+ jtff_log.debug(string.format("Add Tanker Menu for group [%s], player name [%s]",EventData.IniGroupName , EventData.IniPlayerName),"TANKER")
15
15
  if type(InterceptArray) == 'table' then
16
16
  for index, objIntercept in ipairs(InterceptArray) do
17
17
  if (objIntercept.menus[EventData.IniUnit:GetCoalition()]) then
@@ -31,7 +31,7 @@ function Set_CLIENT:OnEventPlayerEnterAircraft(EventData)
31
31
  MENU_GROUP_COMMAND:New( EventData.IniGroup, "All Tankers Info", MenuCoalitionTankerRed, AllTankersInfo, {EventData.IniUnit,EventData.IniGroup} )
32
32
  end
33
33
  local GroupMenu = MENU_GROUP:New( EventData.IniGroup, "My settings" )
34
- debug_msg(string.format("Add Immortal Menu for group [%s], player name [%s]",EventData.IniGroupName , EventData.IniPlayerName))
34
+ jtff_log.debug(string.format("Add Immortal Menu for group [%s], player name [%s]",EventData.IniGroupName , EventData.IniPlayerName),"GENERAL")
35
35
  BASE:SetState( EventData.IniGroup, "isImmortal", false )
36
36
  MENU_GROUP_COMMAND:New( EventData.IniGroup, "Switch immortal status", GroupMenu, switchGroupImmortalStatus, EventData.IniGroup )
37
37
  --if #AIRBOSSArray > 0 then
@@ -43,7 +43,7 @@ function Set_CLIENT:OnEventRefueling(EventData)
43
43
  if (EventData.IniGroup) then
44
44
  local client = CLIENT:Find(EventData.IniDCSUnit)
45
45
  local clientFuel = EventData.IniUnit:GetTemplateFuel()
46
- debug_msg(string.format("[%s] Start to refuel at the tanker %[s], current fuel : %.0f Kg",EventData.IniPlayerName , EventData.TgtUnitName, clientFuel))
46
+ jtff_log.trace(string.format("[%s] Start to refuel at the tanker %[s], current fuel : %.0f Kg",EventData.IniPlayerName , EventData.TgtUnitName, clientFuel),"TANKER")
47
47
  BASE:SetState( client, "Fuel", clientFuel )
48
48
  end
49
49
  end
@@ -51,11 +51,11 @@ function Set_CLIENT:OnEventRefuelingStop(EventData)
51
51
  if (EventData.IniGroup) then
52
52
  local client = CLIENT:Find(EventData.IniDCSUnit)
53
53
  local clientFuelTaken = EventData.IniUnit:GetTemplateFuel() - BASE:GetState(client,"Fuel")
54
- debug_msg(string.format("[%s] Stop to refuel at the tanker %[s], taken %.0f Kg",EventData.IniPlayerName , EventData.TgtUnitName, clientFuelTaken))
54
+ jtff_log.trace(string.format("[%s] Stop to refuel at the tanker %[s], taken %.0f Kg",EventData.IniPlayerName , EventData.TgtUnitName, clientFuelTaken),"TANKER")
55
55
  end
56
56
  end
57
57
 
58
58
  Set_CLIENT_Bleu = SET_CLIENT:New():FilterCoalitions(coalition.side.BLUE):FilterOnce()
59
- debug_msg(string.format("Nbre Blue Client : %i", Set_CLIENT_Bleu:Count()))
59
+ jtff_log.debug(string.format("Nbre Blue Client : %i", Set_CLIENT_Bleu:Count()),"GENERAL")
60
60
  Set_CLIENT_Red = SET_CLIENT:New():FilterCoalitions(coalition.side.RED):FilterOnce()
61
- debug_msg(string.format("Nbre Red Client : %i", Set_CLIENT_Red:Count()))
61
+ jtff_log.debug(string.format("Nbre Red Client : %i", Set_CLIENT_Red:Count()),"GENERAL")
@@ -8,7 +8,7 @@ MenuCoalitionTankerRed = MENU_COALITION:New(coalition.side.RED, "Tankers", MenuC
8
8
  for index, tankerconfig in ipairs(TankersConfig) do
9
9
  if tankerconfig.enable == true then
10
10
  compteur = compteur + 1
11
- env.info('creation Tanker : '.. tankerconfig.groupName..'...')
11
+ jtff_log.info('creation Tanker : '.. tankerconfig.groupName..'...',"TANKER")
12
12
  local objTanker = RECOVERYTANKER:New(UNIT:FindByName(tankerconfig.patternUnit), tankerconfig.groupName)
13
13
  :SetTakeoffCold()
14
14
  :SetRespawnOnOff(tankerconfig.autorespawn)
@@ -26,7 +26,7 @@ for index, tankerconfig in ipairs(TankersConfig) do
26
26
  function objTanker:OnAfterStart(from, event, to)
27
27
  --self:SetTACAN(self.customconfig.tacan.channel, self.customconfig.tacan.morse, self.customconfig.tacan.band )
28
28
  self.spawnAbsTime = timer.getAbsTime()
29
- env.info('popup Tanker : '..self.tanker.GroupName..' at : '..self.spawnAbsTime)
29
+ jtff_log.info('popup Tanker : '..self.tanker.GroupName..' at : '..self.spawnAbsTime,"TANKER")
30
30
  if self.customconfig.escortgroupname then
31
31
  self.escortSpawnObject = SPAWN:NewWithAlias(self.customconfig.escortgroupname,'escort-'.. self.customconfig.groupName)
32
32
  :InitRepeatOnEngineShutDown()
@@ -77,9 +77,9 @@ for index, tankerconfig in ipairs(TankersConfig) do
77
77
  end
78
78
  function objTanker:OnAfterRTB(from, event, to, airbase)
79
79
  if self.customconfig.escortgroupname then
80
- env.info('Tanker RTB: '..self.tanker.GroupName..'...')
80
+ jtff_log.info('RTB: '..self.tanker.GroupName..'...',"TANKER")
81
81
  if self.escortGroupObject:IsAirborne(false) == true then
82
- env.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.tanker.GroupName..'...')
82
+ jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.tanker.GroupName..'...',"TANKER")
83
83
  self.escortGroupObject:RouteRTB(airbase)
84
84
  else
85
85
  --self.escortGroupObject:Destroy(nil, 5)
@@ -89,7 +89,7 @@ for index, tankerconfig in ipairs(TankersConfig) do
89
89
  end
90
90
  function objTanker:OnEventKill(event)
91
91
  if self.customconfig.escortgroupname then
92
- env.info(event.target' Killed !! Sending escort Home')
92
+ jtff_log.info(event.target' Killed !! Sending escort Home',"TANKER")
93
93
  self.escortGroupObject:RouteRTB(AIRBASE:FindByName(self.customconfig.baseUnit))
94
94
  end
95
95
  end
@@ -97,7 +97,7 @@ for index, tankerconfig in ipairs(TankersConfig) do
97
97
  self.tanker:OptionRestrictBurner(true)
98
98
  if ((self.customconfig.escortgroupname) and (self.escortGroupObject)) then
99
99
  if not(GROUP:FindByName(self.escortGroupObject.GroupName)) then
100
- env.info('Respawning escort Group '..self.escortGroupObject.GroupName)
100
+ jtff_log.info('Respawning escort Group '..self.escortGroupObject.GroupName,"TANKER")
101
101
  self.escortGroupObject = self.escortSpawnObject
102
102
  :SpawnAtAirbase(AIRBASE:FindByName(self.customconfig.baseUnit),SPAWN.Takeoff.Cold, self.customconfig.altitude)
103
103
  end
@@ -116,7 +116,7 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
116
116
  if (OnDemandTankersConfig) then
117
117
  for index, OnDemandTanker in ipairs(OnDemandTankersConfig) do
118
118
  if ((OnDemandTanker.type == type) and (OnDemandTanker.enable)) then
119
- debug_msg(string.format('OnDemandTanker : Found type %s Tanker : %s Group!', type, OnDemandTanker.groupName))
119
+ jtff_log.debug(string.format('OnDemandTanker : Found type %s Tanker : %s Group!', type, OnDemandTanker.groupName),"TANKER")
120
120
  if (askedSpeed and askedSpeed > 0) then
121
121
  OnDemandTanker.speed = askedSpeed
122
122
  end
@@ -173,14 +173,14 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
173
173
  end
174
174
  end
175
175
  local set_group_tanker = SET_GROUP:New()
176
- :FilterActive()
177
- :FilterPrefixes(OnDemandTanker.groupName)
178
- :FilterCategories("plane")
179
- :FilterOnce()
176
+ :FilterActive()
177
+ :FilterPrefixes(OnDemandTanker.groupName)
178
+ :FilterCategories("plane")
179
+ :FilterOnce()
180
180
  local aliveTankersGroupList = set_group_tanker:GetSetObjects()
181
181
 
182
182
  local is_tanker_spawned = false
183
- debug_msg(string.format('OnDemandTanker : Looking for a Group corresponding to template %s', string.format("%s-%s", OnDemandTanker.groupName, OnDemandTanker.type)))
183
+ jtff_log.debug(string.format('Looking for a Group corresponding to template %s', string.format("%s-%s", OnDemandTanker.groupName, OnDemandTanker.type)),"TANKER")
184
184
  for index, current_group in ipairs(aliveTankersGroupList) do
185
185
  if (
186
186
  (not(is_tanker_spawned)) and
@@ -191,7 +191,7 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
191
191
  true
192
192
  ) ~= nil)
193
193
  ) then
194
- debug_msg(string.format('OnDemandTanker Found %s corresponding to template %s', current_group.GroupName, string.format("%s-%s", OnDemandTanker.groupName, OnDemandTanker.type)))
194
+ jtff_log.debug(string.format('Found %s corresponding to template %s', current_group.GroupName, string.format("%s-%s", OnDemandTanker.groupName, OnDemandTanker.type)),"TANKER")
195
195
  is_tanker_spawned = true
196
196
  TankerGroup = current_group
197
197
  end
@@ -205,7 +205,7 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
205
205
  RTBAirbase = askedAnchorCoord:GetClosestAirbase2(Airbase.Category.AIRDROME, OnDemandTanker.benefit_coalition)
206
206
  end
207
207
  if (is_tanker_spawned) then
208
- debug_msg(string.format('OnDemandTanker already in air : rerouting %s', OnDemandTanker.groupName))
208
+ jtff_log.debug(string.format('OnDemandTanker already in air : rerouting %s', OnDemandTanker.groupName),"TANKER")
209
209
  TankerGroup:ClearTasks()
210
210
  table.insert(
211
211
  TankerRoute,
@@ -269,7 +269,7 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
269
269
  )
270
270
  )
271
271
  else
272
- debug_msg(string.format('OnDemandTanker Spawning %s', OnDemandTanker.groupName))
272
+ jtff_log.info(string.format('OnDemandTanker Spawning %s', OnDemandTanker.groupName),"TANKER")
273
273
  local SpawnTanker = SPAWN:NewWithAlias(
274
274
  OnDemandTanker.groupName,
275
275
  string.format("%s-%s",OnDemandTanker.groupName,OnDemandTanker.type)
@@ -381,9 +381,9 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
381
381
  end
382
382
  if OnDemandTanker.escortgroupname then
383
383
  TankerGroup.escortSpawnObject = SPAWN:NewWithAlias(OnDemandTanker.escortgroupname,'escort-'.. OnDemandTanker.groupName)
384
- :InitRepeatOnEngineShutDown()
385
- :InitSkill("Excellent")
386
- :OnSpawnGroup(function(SpawnGroup)
384
+ :InitRepeatOnEngineShutDown()
385
+ :InitSkill("Excellent")
386
+ :OnSpawnGroup(function(SpawnGroup)
387
387
  taskGroupEscort({TankerGroup, SpawnGroup})
388
388
  end)
389
389
  TankerGroup.escortGroupObject = spawnRecoveryTankerEscort(TankerGroup.escortSpawnObject,OnDemandTanker)
@@ -442,9 +442,9 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
442
442
  function TankerGroup:OnEventLand(EventData)
443
443
  COORDINATE:RemoveMark(map_marker[self:GetName()])
444
444
  if self.custommconfig.escortgroupname then
445
- env.info('Tanker RTB: '..self.GroupName..'...')
445
+ jtff_log.info('RTB: '..self.GroupName..'...',"TANKER")
446
446
  if self.escortGroupObject:IsAirborne(false) == true then
447
- env.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...')
447
+ jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...',"TANKER")
448
448
  self.escortGroupObject:RouteRTB()
449
449
  else
450
450
  --self.escortGroupObject:Destroy(nil, 5)
@@ -454,9 +454,9 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
454
454
  function TankerGroup:OnEventCrash(EventData)
455
455
  COORDINATE:RemoveMark(map_marker[self:GetName()])
456
456
  if self.custommconfig.escortgroupname then
457
- env.info('Tanker RTB: '..self.GroupName..'...')
457
+ jtff_log.info('RTB: '..self.GroupName..'...',"TANKER")
458
458
  if self.escortGroupObject:IsAirborne(false) == true then
459
- env.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...')
459
+ jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...',"TANKER")
460
460
  self.escortGroupObject:RouteRTB()
461
461
  else
462
462
  --self.escortGroupObject:Destroy(nil, 5)
@@ -466,9 +466,9 @@ function triggerOnDemandTanker(type, askedDuration, askedFL, askedSpeed, askedAn
466
466
  function TankerGroup:OnEventDead(EventData)
467
467
  COORDINATE:RemoveMark(map_marker[self:GetName()])
468
468
  if self.custommconfig.escortgroupname then
469
- env.info('Tanker RTB: '..self.GroupName..'...')
469
+ jtff_log.info('RTB: '..self.GroupName..'...',"TANKER")
470
470
  if self.escortGroupObject:IsAirborne(false) == true then
471
- env.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...')
471
+ jtff_log.info('escort RTB : '.. self.escortGroupObject.GroupName..' Tanker : '..self.GroupName..'...',"TANKER")
472
472
  self.escortGroupObject:RouteRTB()
473
473
  else
474
474
  --self.escortGroupObject:Destroy(nil, 5)
@@ -556,7 +556,7 @@ function TankerMarkHandler:onEvent(event)
556
556
  else
557
557
  cmd = full
558
558
  end
559
- if DEBUG_MSG == true then
559
+ if log_levels[JTFF_LOGLEVEL] <= log_levels['debug'] then
560
560
  trigger.action.outText("Full Text = " .. full, 10)
561
561
  trigger.action.outText("Command = " .. cmd, 10)
562
562
  if param1 ~= nil then trigger.action.outText("type = " .. param1, 10) end
@@ -568,7 +568,7 @@ function TankerMarkHandler:onEvent(event)
568
568
  end
569
569
 
570
570
  if string.find(cmd, "tanker") then
571
- if DEBUG_MSG == true then
571
+ if log_levels[JTFF_LOGLEVEL] <= log_levels['debug'] then
572
572
  trigger.action.outText("DEBUG: On Demand Tanker Started!", 10)
573
573
  end
574
574
  tankersOnDemandArray[#tankersOnDemandArray+1] = triggerOnDemandTanker(