-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathExportInit.lua
More file actions
147 lines (109 loc) · 3.51 KB
/
ExportInit.lua
File metadata and controls
147 lines (109 loc) · 3.51 KB
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
PWDEV = {}
PWDEV.Id = string.format("%08x*",os.time())
PWDEV.PacketSize = 0
PWDEV.SendStrings = {}
PWDEV.PacketNavSize = 0
PWDEV.SendNavStrings = {}
PWDEV.SendNavAllStrings = {}
PWDEV.LastData = {}
PWDEV.LastDataAll = {}
PWDEV.LastDataNav = {}
PWDEV.lastExportTimeHI = 0
PWDEV.lastExportTimeLI = 0
PWDEV.NoLuaExportBeforeNextFrame = false
local PrevPWDEV = {}
PrevPWDEV.LuaExportStart = LuaExportStart
PrevPWDEV.LuaExportStop = LuaExportStop
PrevPWDEV.LuaExportBeforeNextFrame = LuaExportBeforeNextFrame
PrevPWDEV.LuaExportAfterNextFrame = LuaExportAfterNextFrame
PrevPWDEV.LuaExportActivityNextEvent = LuaExportActivityNextEvent
package.path = package.path..";.\\LuaSocket\\?.lua"
package.cpath = package.cpath..";.\\LuaSocket\\?.dll"
local versionFile = lfs.writedir()..[[Scripts\pw-dev_script\version]]
local function loadScript(name)
local fullPath = lfs.writedir() .. [[Scripts\pw-dev_script\]] .. name
local status, result = pcall(function()
return dofile(fullPath)
end)
if not status then
return nil
end
return result
end
loadScript("lib\\Init.lua")
loadScript("Config.lua")
PWDEV.utf8 = loadScript("lib\\utf8.lua")
loadScript("lib\\Tools.lua")
loadScript("lib\\Maps.lua")
PWDEV.Displays = loadScript("lib\\Displays.lua")
local separator = PWDEV.Config.Separator
PWDEV.FoundDCSModule = false
PWDEV.FoundFCModule = false
PWDEV.FoundNoModul = true
function PWDEV.Start()
PWDEV.Tools.createUDPSender()
PWDEV.Tools.createUDPListner()
PWDEV.Init.CheckDcs()
local version = LoGetVersionInfo()
PWDEV.Init.CheckDcsVersionId(version)
PWDEV.AF = {}
PWDEV.NoLuaExportBeforeNextFrame = false
PWDEV.Tools.SelectModule()
local scriptVer = PWDEV.Tools.GetFileData(versionFile, 1)
PWDEV.Tools.playerId = PWDEV.Tools.GetPlayerId()
PWDEV.Tools.SendShortData("EX=ON;Ver="..PWDEV.Init.VersionStr .. separator.."VId="..PWDEV.Init.VersionId..separator.."MOE="..PWDEV.Init.CheckObjectExport()..separator.."MSE="..PWDEV.Init.CheckSensorExport()..separator.."MPE="..PWDEV.Init.CheckOwnshipExport()..separator.."SV="..scriptVer..separator.."CV="..PWDEV.Config.FileVersion..separator .. "SC1" .. separator)
end
function PWDEV.ActivityNextEvent()
PWDEV.coProcessArguments_BeforeNextFrame = coroutine.create(PWDEV.Tools.ProcessInput)
coStatus = coroutine.resume(PWDEV.coProcessArguments_BeforeNextFrame)
if PWDEV.NoLuaExportBeforeNextFrame == false then
PWDEV.Tools.ProcessOutput()
end
end
function PWDEV.Stop()
PWDEV.Tools.FlushDataDevice()
PWDEV.Tools.SendShortData("EX=OF")
PWDEV.UDPsender:close()
if PWDEV.Config.Listener then
PWDEV.UDPListener:close()
end
PWDEV.ModuleName = nil
PWDEV.FoundNoModul = false
end
LuaExportStart = function()
local status, err = pcall(function()
PWDEV.Start()
end)
if PrevPWDEV.LuaExportStart then
PrevPWDEV.LuaExportStart()
end
end
function LuaExportBeforeNextFrame()
if PrevPWDEV.LuaExportBeforeNextFrame then
PrevPWDEV.LuaExportBeforeNextFrame()
end
end
function LuaExportAfterNextFrame()
if PWDEV.NoLuaExportBeforeNextFrame then
PWDEV.Tools.ProcessOutput()
end
if PrevPWDEV.LuaExportAfterNextFrame then
PrevPWDEV.LuaExportAfterNextFrame()
end
end
function LuaExportActivityNextEvent(currenttime)
local tNext = currenttime
local status, err = pcall(function()
PWDEV.ActivityNextEvent()
end)
tNext = tNext + PWDEV.Config.ExportInterval
return tNext
end
LuaExportStop = function()
local status, err = pcall(function()
PWDEV.Stop()
end)
if PrevPWDEV.LuaExportStop then
PrevPWDEV.LuaExportStop()
end
end