-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathServiceProvider.lua
157 lines (139 loc) · 5.9 KB
/
ServiceProvider.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
-- ServiceProvider v0.3: a script by buur. It provides radio and other stuff from servic provider like tanker, AWACS or FAC
-- ToDo: FARPS and Carrier. JTACs with more than one target will have several entries for their own position
-- Changelog: switched from the actual JTAC callsign to the callsign wich is given in the mission
function infoAWACS()
local msg = {}
msg[#msg + 1] = "AWACS\\EWR:"
msg[#msg + 1]='\n'
local ServiceProvider = coalition.getServiceProviders(2 , 1 )
if next(ServiceProvider) ~= nil then
do
for ke,val in pairs(ServiceProvider)
do
if ServiceProvider[ke]:getCallsign() then
callsign = ServiceProvider[ke]:getCallsign()
else
callsign = "N/A"
end
local nametype = ServiceProvider[ke]:getTypeName()
msgstr = nametype.." "..callsign.." "
local ServiceProvider = ServiceProvider[ke]:getGroup():getName()
local groupServiceProvider = mist.getGroupData(ServiceProvider)
local routeServiceProvider = mist.getGroupRoute(ServiceProvider , true)
Modulation = {[0]="AM", [1]="FM"}
if groupServiceProvider["frequency"] then -- get the values from lua database only when they exists
msgstr = msgstr.."Freq: "..groupServiceProvider["frequency"].." "..Modulation[groupServiceProvider["modulation"]].." "
local t=mist.getGroupRoute( ServiceProvider , true )[1]["task"]["params"]["tasks"]
elseif routeServiceProvider[1]["task"]["params"]["tasks"][1]["id"] == "EWR" then
Modulation = {[0]="AM", [1]="FM"}
EWR_tasks = routeServiceProvider[1]["task"]["params"]["tasks"]
for key,value in pairs(EWR_tasks)
do
if EWR_tasks[key]["id"] == "WrappedAction" then
local EWR_frequency = EWR_tasks[key]["params"]["action"]["params"]["frequency"]
local EWR_Modulation = EWR_tasks[key]["params"]["action"]["params"]["modulation"]
msgstr = msgstr.."Freq: "..EWR_frequency/1000000 .." "..Modulation[EWR_Modulation]
end
end
end
msg[#msg + 1] = msgstr
msg[#msg + 1]='\n'
end
trigger.action.outText(table.concat(msg), 30, false)
end
end
end
function infoFAC()
JTAC_Callsigns = {
[1] = "Axeman",
[2] = "Darknight",
[3] = "Warrior",
[4] = "Pointer",
[5] = "Eyeball",
[6] = "Moonbeam",
[7] = "Whiplash",
[8] = "Finger",
[9] = "Pinpoint",
[10] = "Ferret",
[11] = "Shaba",
[12] = "Playboy",
[13] = "Hammer",
[14] = "Jaguar",
[15] = "Deathstar",
[16] = "Anvil",
[17] = "Firefly",
[18] = "Mantis",
[19] = "Badger"}
msg = {}
msg[#msg + 1] = "FAC:"
msg[#msg + 1]='\n'
local ServiceProvider = coalition.getServiceProviders(2 , 3 )
if next(ServiceProvider) ~= nil then
do
for ke,val in pairs(ServiceProvider)
do
local callsign = ServiceProvider[ke]:getCallsign()
local curPoint = ServiceProvider[ke]:getPoint()
local lat, lon, alt = coord.LOtoLL(curPoint)
local grid = coord.LLtoMGRS(lat,lon)
local msgstr = callsign.." ".."at Position: " ..grid.UTMZone .. ' ' .. grid.MGRSDigraph .. ' '.. grid.Easting .. ' ' .. grid.Northing.." "--..lat.." "..lon
local ServiceProvider = ServiceProvider[ke]:getGroup():getName()
local t=mist.getGroupRoute( ServiceProvider , true )[1]["task"]["params"]["tasks"]
for key,value in pairs(t)
do
local actual_JTAC_Callsigns = t[key]["params"]["callname"]
local actual_JTAC_Callsigns_name = JTAC_Callsigns[actual_JTAC_Callsigns]
callsign_short = callsign:sub(1,-3)
if (((t[key]["id"] == "FAC_AttackGroup") or (t[key]["id"] == "FAC") or (t[key]["id"] == "FAC_EngageGroup" ))and (actual_JTAC_Callsigns_name == callsign_short)) then
local Modulation = {[0]="AM", [1]="FM"}
local FAC_frequency = (t[key]["params"]["frequency"])
local FAC_Modulation = (t[key]["params"]["modulation"])
local msgstr = msgstr.."Freq: "..FAC_frequency/1000000 .." "..Modulation[FAC_Modulation].." "
msg[#msg + 1] = msgstr
msg[#msg + 1]='\n'
end
end
end
trigger.action.outText(table.concat(msg), 30, false)
end
end
end
function infoTanker()
msg = {}
msg[#msg + 1] = "Tanker:"
msg[#msg + 1]='\n'
local ServiceProvider = coalition.getServiceProviders(2 , 2 )
if next(ServiceProvider) ~= nil then
do
for ke,val in pairs(ServiceProvider)
do
local callsign = ServiceProvider[ke]:getCallsign()
local nametype = ServiceProvider[ke]:getTypeName()
msgstr = nametype.." "..callsign.." "
local ServiceProvider = ServiceProvider[ke]:getGroup():getName()
local groupServiceProvider = mist.getGroupData(ServiceProvider)
Modulation = {[0]="AM", [1]="FM"}
if groupServiceProvider["frequency"] then -- get the values from lua database only when they exists
msgstr = msgstr.."Freq: "..groupServiceProvider["frequency"].." "..Modulation[groupServiceProvider["modulation"]].." "
local t=mist.getGroupRoute( ServiceProvider , true )[1]["task"]["params"]["tasks"]
for key,value in pairs(t)
do
if t[key]["id"] == "WrappedAction" then
local TCN_channel = t[key]["params"]["action"]["params"]["channel"]
local TCN_modeChannel = t[key]["params"]["action"]["params"]["modeChannel"]
local TCN_callsign = t[key]["params"]["action"]["params"]["callsign"]
local msgstr = msgstr.."TCN: "..TCN_channel..TCN_modeChannel.." "..TCN_callsign
msg[#msg + 1] = msgstr
msg[#msg + 1]='\n'
end
end
end
end
trigger.action.outText(table.concat(msg), 30, false)
end
end
end
local displayInfo = missionCommands.addSubMenuForCoalition(2, "Display Information", nil)
local displayAWACS = missionCommands.addCommandForCoalition(2 , "Diplay AWACS\\EWR" , displayInfo , infoAWACS, {} )
local displayFAC = missionCommands.addCommandForCoalition(2 , "Diplay FAC" , displayInfo , infoFAC, {} )
local displayTanker = missionCommands.addCommandForCoalition(2 , "Diplay Tanker" , displayInfo , infoTanker, {} )