@jtff/miztemplate-lib 3.10.4 → 3.10.6

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.
@@ -32,15 +32,15 @@ function Set_CLIENT:OnEventPlayerEnterAircraft(EventData)
32
32
  for index, objQRA in ipairs(QRAArray) do
33
33
  if (MenuCoalitionQRA[clientUnit:GetCoalition()]) and (objQRA.customconfig.type == JTFF_QRA.Type.TangoAuto) then
34
34
  objQRA.menu[clientUnit:GetCoalition()] = MENU_GROUP_COMMAND:New(
35
- clientGroup,
36
- "Trigger " .. objQRA.customconfig.name,
37
- MenuCoalitionQRA[clientUnit:GetCoalition()],
38
- QRATrigger,
39
- {
40
- objQRA,
41
- clientUnit:GetName(),
42
- index,
43
- }
35
+ clientGroup,
36
+ "Trigger " .. objQRA.customconfig.name,
37
+ MenuCoalitionQRA[clientUnit:GetCoalition()],
38
+ QRATrigger,
39
+ {
40
+ objQRA,
41
+ clientUnit:GetName(),
42
+ index,
43
+ }
44
44
  )
45
45
  end
46
46
  end
@@ -72,8 +72,8 @@ function Set_CLIENT:OnEventRefueling(EventData)
72
72
  local tankerUnit = UNIT:Find(EventData.initiator)
73
73
  local refuelingUnitsSearchRadiusMeters = 150
74
74
  local tankerUnitName = 'unknown'
75
- local client = nil
76
- local clientUnit = nil
75
+ local client
76
+ local clientUnit
77
77
  local clientFuel = 0
78
78
  local clientName = 'unknown'
79
79
  if (type(tankerUnit) ~= 'nil') then
@@ -83,60 +83,60 @@ function Set_CLIENT:OnEventRefueling(EventData)
83
83
  tankerUnitName = tankerUnit:GetName()
84
84
  local isTanker, tankerRefuelSystem = tankerUnit:IsTanker()
85
85
  local refuelingUnitsSet = tankerUnit
86
- :GetCoordinate()
87
- :ScanUnits(refuelingUnitsSearchRadiusMeters)
88
- :FilterCoalitions(tankerUnit:GetCoalitionName())
89
- :FilterActive(true)
90
- :FilterAlive()
91
- :FilterFunction(
92
- function(unit)
93
- local isRefuelable, unitrefuelsystem = unit:IsRefuelable()
94
- return isRefuelable and unitrefuelsystem == tankerRefuelSystem
95
- end)
96
- :ForEachUnit(
97
- function(unit)
98
- local clientRefueling = CLIENT:Find(unit:GetDCSObject(), true)
99
- --trigger.action.outText(string.format("testing unit %s for clientRefuelableSet",unit:GetName()), 90)
100
- if type(clientRefueling) ~= 'nil' then
101
- clientRefuelableSet:AddObject(clientRefueling)
102
- jtff_log.trace(string.format("adding %s to clientRefuelableSet (refuelable aicrafts near tanker)",clientRefueling:GetPlayer()),"TANKER")
103
- end
86
+ :GetCoordinate()
87
+ :ScanUnits(refuelingUnitsSearchRadiusMeters)
88
+ :FilterCoalitions(tankerUnit:GetCoalitionName())
89
+ :FilterActive(true)
90
+ :FilterAlive()
91
+ :FilterFunction(
92
+ function(unit)
93
+ local isRefuelable, unitrefuelsystem = unit:IsRefuelable()
94
+ return isRefuelable and unitrefuelsystem == tankerRefuelSystem
95
+ end)
96
+ :ForEachUnit(
97
+ function(unit)
98
+ local clientRefueling = CLIENT:Find(unit:GetDCSObject(), true)
99
+ --trigger.action.outText(string.format("testing unit %s for clientRefuelableSet",unit:GetName()), 90)
100
+ if type(clientRefueling) ~= 'nil' then
101
+ clientRefuelableSet:AddObject(clientRefueling)
102
+ jtff_log.trace(string.format("adding %s to clientRefuelableSet (refuelable aicrafts near tanker)",clientRefueling:GetPlayer()),"TANKER")
104
103
  end
104
+ end
105
105
  )
106
106
  jtff_log.trace(string.format("refuelingUnitSet (refuelable aicrafts near tanker) : count = %d",refuelingUnitsSet:Count()),"TANKER")
107
107
  jtff_log.trace(string.format("clientRefuelableSet (client refuelable aircrafts near tanker): count = %d",clientRefuelableSet:Count()),"TANKER")
108
108
  if clientRefuelableSet:Count() >= 1 then
109
109
  if clientRefuelableSet:Count() >= 2 then
110
110
  clientRefuelableSet:ForEachClient(
111
- function(client)
112
- local clientUnit = client:GetClientGroupUnit()
113
- local clientFuel = clientUnit:GetFuel() * clientUnit:GetDesc().fuelMassMax
114
- if not(BASE:GetState(clientUnit, "isRefueling")) then
115
- local mytimer=TIMER:New(
116
- function(unit, clientObject, initialFuelState, tankerName)
117
- if (unit:GetFuel() * unit:GetDesc().fuelMassMax-initialFuelState >= 0) then
118
- local clientName = clientObject:GetPlayer() or unit:GetName()
119
- BASE:SetState( unit, "isRefueling", true )
120
- BASE:SetState( unit, "FuelState", initialFuelState )
121
- jtff_log.info(
122
- string.format(
123
- "[%s] Start refueling at the tanker [%s], current fuel : %.0f Lbs",
124
- clientName,
125
- tankerName,
126
- UTILS.kg2lbs(initialFuelState)
127
- ),
128
- "TANKER"
129
- )
130
- end
131
- end,
132
- clientUnit,
133
- client,
134
- clientFuel,
135
- tankerUnitName
136
- )
137
- mytimer:Start(2)
138
- end
111
+ function(curClient)
112
+ local clientUnitObject = curClient:GetClientGroupUnit()
113
+ local clientFuelMassMax = clientUnitObject:GetFuel() * clientUnitObject:GetDesc().fuelMassMax
114
+ if not(BASE:GetState(clientUnitObject, "isRefueling")) then
115
+ local mytimer=TIMER:New(
116
+ function(unit, clientObject, initialFuelState, tankerName)
117
+ if (unit:GetFuel() * unit:GetDesc().fuelMassMax-initialFuelState >= 0) then
118
+ local clientNameString = clientObject:GetPlayer() or unit:GetName()
119
+ BASE:SetState( unit, "isRefueling", true )
120
+ BASE:SetState( unit, "FuelState", initialFuelState )
121
+ jtff_log.info(
122
+ string.format(
123
+ "[%s] Start refueling at the tanker [%s], current fuel : %.0f Lbs",
124
+ clientNameString,
125
+ tankerName,
126
+ UTILS.kg2lbs(initialFuelState)
127
+ ),
128
+ "TANKER"
129
+ )
130
+ end
131
+ end,
132
+ clientUnitObject,
133
+ curClient,
134
+ clientFuelMassMax,
135
+ tankerUnitName
136
+ )
137
+ mytimer:Start(2)
139
138
  end
139
+ end
140
140
  )
141
141
  else
142
142
  client = clientRefuelableSet:GetFirst()