blob: 4c37469c2c706860d9663a7b83da42005b2904cd (
plain)
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
mOldSector = -1
mLastSectors = {0.00, 0.00, 0.00}
mBestSectors = {0.00, 0.00, 0.00}
mSectorSplit_Vs_LastSector = 0.0
mSectorSplit_Vs_BestSector = 0.0
mSectorSplit_Vs_BestLap = 0.0
mSectorSplit = 0
function SectorUpdate()
local sector = GetCarInfo("sector")
local laps = GetContextInfo("laps")
if mOldSector == -1 and sector < 3 then
return
elseif mOldSector == -1 and sector == 3 then
-- first lap
print (" Almost clean lap ... ")
--print ("lap "..laps.." / sector "..sector.." ["..mOldSector.."]")
mOldSector = 0
elseif mOldSector == 0 and sector ~= 1 then
return
elseif mOldSector == 0 then
-- start of first clean lap
print (" >>> Clean Lap ! <<< ")
--print ("lap "..laps.." / sector "..sector.." ["..mOldSector.."]")
mOldSector = 1
end
if mOldSector > 0 and mOldSector ~= sector then
mSectorSplit = GetTicks() + mSectorSplitDelay
-- Std values ------------------------
local s1 = GetTimeInfo("sector1")
local s2 = GetTimeInfo("sector2")
local s3 = GetTimeInfo("sector3")
local ls1 = GetTimeInfo("lastsector1")
local ls2 = GetTimeInfo("lastsector2")
local ls3 = GetTimeInfo("lastsector3")
local llt = GetTimeInfo("lastlaptime")
local bs1 = GetTimeInfo("bestsector1")
local bs2 = GetTimeInfo("bestsector2")
local bs3 = GetTimeInfo("bestsector3")
local blt = GetTimeInfo("bestlaptime")
--------------------------------------
---------------------------------------------------------------------
local Ls1 = mLastSectors[1]
local Ls2 = mLastSectors[2]
local Ls3 = mLastSectors[3]
local Llt = 0.0
local Bs1 = mBestSectors[1]
local Bs2 = mBestSectors[2]
local Bs3 = mBestSectors[3]
local Blt = 0.0
-- Sectors splits --------------------------------------------------
mSectorSplit_Vs_LastSector = 0.0
mSectorSplit_Vs_BestSector = 0.0
mSectorSplit_Vs_BestLap = 0.0
if mOldSector == 1 or (mOldSector > 1 and mSectorSplitCumulate) then
mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s1 - Ls1
mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s1 - Bs1
mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s1 - bs1
end
if mOldSector == 2 or (mOldSector > 2 and mSectorSplitCumulate) then
mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s2 - Ls2
mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s2 - Bs2
mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s2 - bs2
end
if mOldSector == 3 then
mSectorSplit_Vs_LastSector = mSectorSplit_Vs_LastSector + s3 - Ls3
mSectorSplit_Vs_BestSector = mSectorSplit_Vs_BestSector + s3 - Bs3
mSectorSplit_Vs_BestLap = mSectorSplit_Vs_BestLap + s3 - bs3
end
-- Compute values ----------------------------------------------------
if mOldSector == 1 then
if Bs1 ~= 0 then Bs1 = math.min(Bs1, s1) else Bs1 = s1 end
Ls1 = s1
elseif mOldSector == 2 then
if Bs2 ~= 0 then Bs2 = math.min(Bs2, s2) else Bs2 = s2 end
Ls2 = s2
elseif mOldSector == 3 then
if Bs3 ~= 0 then Bs3 = math.min(Bs3, s3) else Bs3 = s3 end
Ls3 = s3
end
mBestSectors[1] = Bs1
mBestSectors[2] = Bs2
mBestSectors[3] = Bs3
mLastSectors[1] = Ls1
mLastSectors[2] = Ls2
mLastSectors[3] = Ls3
if Bs1 ~= 0 and Bs2 ~= 0 and Bs3 ~= 0 then Blt = Bs1 + Bs2 + Bs3 end
Llt = Ls1 + Ls2 + Ls3 -- used for Debug only
----------------------------------------------------------------------
-- Sectors times debugging ----------------------------------------------------------------
if mOldSector == 1 then print (" sector " ..mOldSector)
elseif mOldSector == 2 then print (" sector " ..mOldSector)
elseif mOldSector == 3 then print (" sector " ..mOldSector)
else
print ("sector "..sector)
end
print ("[curr] " .. s1 .. " " .. s2 .. " " .. s3 )
print ("[last] " ..ls1 .. " " ..ls2 .. " " ..ls3 )
print ("[Last] " ..Ls1 .. " " ..Ls2 .. " " ..Ls3 .. " | " .. (mSectorSplit_Vs_LastSector) )
print ("[best] " ..bs1 .. " " ..bs2 .. " " ..bs3 .. " | " .. (mSectorSplit_Vs_BestLap ) )
print ("[Best] " ..Bs1 .. " " ..Bs2 .. " " ..Bs3 .. " | " .. (mSectorSplit_Vs_BestSector) )
-------------------------------------------------------------------------------------------
print (" last best")
print ("[lapt] " .. llt .. " - " .. blt )
--print ("[sect] " .. (ls1+ls2+ls3) .. " - " .. (bs1+bs2+bs3) )
print ("[comp] " .. Llt .. " - " .. Blt )
if sector == 1 then
-- new lap
print ("")
print ("--- lap "..laps.." --------------------------------")
end
mOldSector = sector
end
end
function GetCurrentSectorBestTime()
local sector = GetCarInfo("sector")
if sector == 1 then lpt = mBestSectors[1]
elseif sector == 2 then lpt = mBestSectors[2]
elseif sector == 3 then lpt = mBestSectors[3]
else lpt = 0.0
end
end
function GetCurrentSectorTime()
local sector = GetCarInfo("sector")
lt = GetTimeInfo("laptime")
if sector == 1 then
lpt = GetTimeInfo("lastsector1")
lpt = lt
elseif sector == 2 then
lpt = lt - GetTimeInfo("sector1")
else
-- sector 3
lpt = lt - GetTimeInfo("sector1") - GetTimeInfo("sector2")
end
end
function GetPreviousSectorBestTime()
local sector = GetCarInfo("sector")
if sector == 1 then lpt = mBestSectors[3]
elseif sector == 2 then lpt = mBestSectors[1]
elseif sector == 3 then lpt = mBestSectors[2]
else lpt = 0.0
end
return lpt
end
function GetPreviousSectorTime()
local sector = GetCarInfo("sector")
if sector == 1 then lpt = mLastSectors[3]
elseif sector == 2 then lpt = mLastSectors[1]
elseif sector == 3 then lpt = mLastSectors[2]
else lpt = 0.0
end
return lpt
end
-- return delta time vs last/best time + sector splits
function RealTimeDiff_SectorSplits(Best, Lap)
local lpt = 0.0
if mSectorSplit ~= nil and mSectorSplit > GetTicks() then
if Best and Lap then lpt = mSectorSplit_Vs_BestLap
elseif Best then lpt = mSectorSplit_Vs_BestSector
else lpt = mSectorSplit_Vs_LastSector
end
else
-- display delta by default
if Best then lpt = GetTimeInfo("realdiffbest")
else lpt = GetTimeInfo("realdifflast")
end
end
return lpt
end
|