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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
|
-- ============================================================
-- Left and Right Panel functions
-- ============================================================
--require ("scripts/gugus/sector.lua")
--------------------------------
-- 0.0.0:00:0 [0.] 0:00.0.0:0 --
-- Ll : Lr [0.] Rl . Rr --
-- L [0.] R --
--------------------------------
mDebug = GetTicks()
function GetWheelTemp(what)
local sim = GetContextInfo("simulation")
local unit = GetContextInfo("speedmetric")
local temp = 0
if what == "wtfl" then temp = GetCarInfo("wheeltempfrontleft")
elseif what == "wtfr" then temp = GetCarInfo("wheeltempfrontright")
elseif what == "wtrr" then temp = GetCarInfo("wheeltemprearright")
elseif what == "wtrl" then temp = GetCarInfo("wheeltemprearleft")
elseif what == "btfl" then temp = GetCarInfo("braketempfrontleft")
elseif what == "btfr" then temp = GetCarInfo("braketempfrontright")
elseif what == "btrr" then temp = GetCarInfo("braketemprearright")
elseif what == "btrl" then temp = GetCarInfo("braketemprearleft")
end
if isAppRFactor(sim) or sim == "GTR2.exe" then temp = KtoC(temp) end
-- convert from C to K if needed
return GetTemp(temp, unit)
end
function GetWheelPressure(what)
local press = 0
if what == "wpfl" then press = GetCarInfo("wheelpressfrontleft")
elseif what == "wpfr" then press = GetCarInfo("wheelpressfrontright")
elseif what == "wprr" then press = GetCarInfo("wheelpressrearright")
elseif what == "wprl" then press = GetCarInfo("wheelpressrearleft")
end
return press / 6.88
end
function GetString(what, where)
-- where should be one of : L, R, Ll, Lr, Rl, Rr
local fullSize = false
if where == "R" or where == "L" then fullSize = true end
local Output = " "
if fullSize then Output = " " end
-- GENERAL
-- speed
if what == "speed" then
if fullSize then
Output = string.format(" %3d", GetCarInfo("speed"))
else
Output = string.format("%3d", GetCarInfo("speed"))
end
-- rpm
elseif what == "rpm" then
if fullSize then
Output = string.format(" %5d", GetCarInfo("rpm"))
else
Output = string.format("%5d", GetCarInfo("rpm"))
end
-- gear
elseif what == "gear" then
Output = string.format("%d", GetCarInfo("gear"))
elseif what == "pos" then
Output = string.format("P%02d", GetContextInfo("position"))
-- sector
elseif what == "sector" then
if where == "Ll" or where == "Rl" then
Output = string.format("S%1d ", GetCarInfo("sector"))
elseif where == "Lr" or where == "Rr" then
Output = string.format(" S%1d", GetCarInfo("sector"))
else -- fullSize
Output = string.format(" S%1d ", GetCarInfo("sector"))
end
-- LAPS
-- laps completed
elseif what == "laps" then
local laps = GetContextInfo("laps")
if fullSize then
Output = string.format("L %3d ", laps)
else
if laps > 99 then
Output = string.format("%03d", laps)
else
Output = string.format("L%02d", laps)
end
end
-- total laps
elseif what == "totallaps" then
local totallaps = GetContextInfo("lapscount")
if fullSize then
if totallaps ~= 0 then
Output = string.format("t %3d ", totallaps)
else
Output = "t -- "
end
else
if totallaps > 99 then
Output = string.format("%03d", totallaps)
elseif totallaps ~= 0 then
Output = string.format("t%02d", totallaps)
else
Output = "t--"
end
end
-- remaining laps
elseif what == "remainlaps" then
tl = GetContextInfo("lapscount")
l = GetContextInfo("laps")
if fullSize then
if tl ~= 0 then
Output = string.format("r %3d ", tl - l)
else
Output = "r -- "
end
else
if tl ~= 0 then
Output = string.format("r%03d", tl - l)
else
Output = "r--"
end
end
-- FUEL
-- fuel
elseif what == "fuel" then
fuel = GetFuel(GetCarInfo("fuel"), GetContextInfo("speedmetric"))
if fullSize then
if fuel >= 100 then
Output = string.format ( "F. %4d", fuel )
elseif fuel >= 10 then
Output = string.format ( "F. %2.1f", fuel )
else
Output = string.format ( "F. %1.1f", fuel )
end
else
if fuel >= 100 then
-- specific for euro truck :)
if fuel >= 999 then
Output = "999"
else
Output = string.format("%03d", round(fuel) % 1000 )
end
elseif fuel >= 10 then
Output = string.format("F%2d", math.floor(fuel) )
elseif fuel >= 1 then
if where == "Rl" then
-- no dot after second digit
Output = string.format("F %d", fuel )
else
Output = string.format("F%1.1f", fuel )
end
else
if where == "Lr" then
-- no dot after first digit..
Output = string.format("F .%d", fuel * 100 )
else
Output = string.format("F.%02d", fuel * 100 )
end
end
end
-- remaining laps with fuel
elseif what == "remainlapswithfuel" then
local rl = GetCarInfo("remainlapsintank")
if rl ~= 0 then
if rl > 99 then
Output = "r99"
else
Output = string.format("r%02d", GetCarInfo("remainlapsintank"))
end
else
Output = "r--"
end
-- ENGINE TEMP
-- water temp
elseif what == "water" then
wt = GetTemp(GetCarInfo("watertemp"), GetContextInfo("speedmetric"))
if fullSize then
Output = string.format("w %3d°", wt)
else
Output = string.format("%3d", wt)
end
-- oil temp
elseif what == "oil" then
oil = GetTemp(GetCarInfo("oiltemp"), GetContextInfo("speedmetric"))
if fullSize then
Output = string.format("o %3d°", oil)
else
Output = string.format("%3d", oil)
end
-- WHEEL TEMP
-- WHEEL PRESS
-- BRAKE TEMP
elseif what == "wtfl" or what == "wtfr" or what == "wtrl" or what == "wtrr"
or what == "btfl" or what == "btfr" or what == "btrl" or what == "btrr" then
if fullSize then
Output = string.format("%s.%3d", what, GetWheelTemp(what))
else
Output = string.format("%3d", GetWheelTemp(what))
end
elseif what == "wpfl" or what == "wpfr" or what == "wprl" or what == "wprr" then
if fullSize then
Output = string.format("%s.%3d", what, GetWheelPressure(what))
else
Output = string.format("%3d", GetWheelPressure(what))
end
-- DISTANCES
-- track size
elseif what == "track" then
track = GetContextInfo("tracksize") / 1000
if fullSize then
Output = string.format(" %2.3f", track)
else
if track >= 10. then
if where ~= "Rl" then
Output = string.format("%2.1f", track)
else
Output = string.format(" %2d", track)
end
else
if where ~= "Lr" then
Output = string.format("%1.2f", track)
else
Output = string.format(" %1.1f", track)
end
end
end
-- total distance
elseif what == "trip" then
distance = GetContextInfo("lapdistance") / 1000
if fullSize then
Output = string.format(" %2.3f", distance)
else
if distance >= 10. then
if where ~= "Rl" then
Output = string.format("%2.1f", distance)
else
Output = string.format(" %2d", distance)
end
else
if where ~= "Lr" then
Output = string.format("%1.2f", distance)
else
Output = string.format(" %1.1f", distance)
end
end
end
-- track %
elseif what == "trackpercent" then
track = GetContextInfo("lapdistance")
distance = GetContextInfo("lapdistance")
progress = (distance % track) * 100 / track
if fullSize then
Output = string.format(" %3.1f", progress)
else
Output = string.format("%3d", progress)
end
--
-- Formula 1
--
-- kers
elseif swValue == 27 then Output = GetCarInfo("kers")
-- kers max
elseif swValue == 28 then Output = GetCarInfo("kersmax")
-- kers percent
elseif swValue == 29 then Output = round(GetCarInfo("kers") * 100 / GetCarInfo("kersmax"))
-- drs
elseif swValue == 30 then Output = GetCarInfo("drs")
-- PIT
elseif what == "inpit" then
Output = GetContextInfo("inpits")
-- Safety Car
elseif what == "safetycar" then
Output = GetCarInfo("safetycar")
end
return Output
end
function GetTimeString(what, where)
-- most commonly used vars
local time = nil
local splitTime = false
local Output = " "
local fullSize = where == "L" or where == "R"
if fullSize then Output = " " end
--
-- TIMES
--
-- current lap time
if what == "currentlap" then time = GetTimeInfo("laptime")
-- best lap time
elseif what == "bestlaptime" then time = GetTimeInfo("bestlaptime")
-- last lap time
elseif what == "lastlaptime" then time = GetTimeInfo("lastlaptime")
-- virtual best lap time (best sectors)
elseif what == "virtualbestlap" then
if mBestSectors[1] ~= 0 and mBestSectors[2] ~= 0 and mBestSectors[3] ~= 0 then
time = mBestSectors[1] + mBestSectors[2] + mBestSectors[3]
end
-- current sector (1, 2 and 3)
elseif what == "currentsector" then
time = GetSectorTime("", 0)
-- previous sector (3, 1 and 2)
elseif what == "lastsector" then
time = GetSectorTime("", -1)
-- previous best sector (3, 1 and 2)
elseif what == "lastsectorbest" then
time = GetSectorTime("BEST", -1)
-- lastlap sector (1, 2 and 3)
elseif what == "lastlapsector" then
time = GetSectorTime("last", 0)
-- bestlap sector (1, 2 and 3)
elseif what == "bestlapsector" then
time = GetSectorTime("best", 0)
-- sector split
elseif what == "bestsector" then
time = GetSectorTime("BEST", 0)
-- sector split
elseif what == "lastsectorsplitVSlast" then
time = GetSectorSplit("last", -1)
splitTime = true
-- best lap sector split
elseif what == "lastsectorsplitVSbestlap" then
time = GetSectorSplit("best", -1)
splitTime = true
-- best sector split
elseif what == "lastsectorsplitVSbest" then
time = GetSectorSplit("BEST", -1)
splitTime = true
elseif what == "currentsectorsplitVSlast" then
time = GetSectorSplit("last", 0)
splitTime = true
-- best lap sector split
elseif what == "currentsectorsplitVSbestlap" then
time = GetSectorSplit("best", 0)
splitTime = true
-- best sector split
elseif what == "currentsectorsplitVSbest" then
time = GetSectorSplit("BEST", 0)
splitTime = true
-- real time diff vs best
elseif what == "diffbest" then
time = GetTimeInfo("realdiffbest")
splitTime = true
-- real time diff vs last
elseif what == "difflast" then
time = GetTimeInfo("realdifflast")
splitTime = true
-- time remaining
elseif what == "timeremaining" then
time = GetTimeInfo("timeremaining")
-- time elapsed
elseif what == "timeelapsed" then
time = GetTimeInfo("timetotalelapsed")
-- system time
elseif what == "clock" then
time = GetTimeInfo("systemtime")
end
if what ~= clock then
Output = TimeToString(time, where, splitTime)
else
local hr, mn, sc, cs, ms = timeDispatcher(time)
Output = string.format( " %2d.%02d ", hr, mn)
end
if Output == nil then Output = "" end
ticks = GetTicks()
if mDebug ==nil or ticks < mDebug then
if time ~= nil then
if splitTime then
--print ("funct: ".. what.. " ["..where.."] -> " ..time.." =[split]= ".. Output )
else
--print ("funct: ".. what.. " ["..where.."] -> " ..time.." == ".. Output )
end
else
print ("funct: ".. what.. " ["..where.."] -> nil == ".. Output )
end
mDebug = ticks + 10000
end
return Output
end
function GetSectorTime(what, which)
local sector = GetCarInfo("sector") + which
if sector == 0 then sector = 3 end
local time = 0.
if what == "" and which == 0 then
time = GetTimeInfo("laptime")
if sector == 1 then time = time
elseif sector == 2 then time = time - GetTimeInfo("sector1")
elseif sector == 3 then time = time - GetTimeInfo("sector1") - GetTimeInfo("sector2")
end
elseif what == "BEST" then
time = mBestSectors[sector]
else
GetTimeInfo(string.format("%ssector%d", what, sector))
end
return time
end
function GetSectorSplit(what, which)
return GetSectorTime("", which) - GetSectorTime(what, which)
end
function TimeToString(time, where, splitTime)
local Output = "000"
if where == "R" or where == "L" then Output = "0.00.000" end
if time ~= nil then
local hr = 0
local mn = 0
local sc = 0
local cs = 0
local ms = 0
hr, mn, sc, cs, ms = timeDispatcher(time)
-- blinking second separator
local dot = "."
local colon = ":"
local min = "'"
--if cs >= 50 then
-- dot = ""
-- colon = "."
-- min = " "
--end
if splitTime == false then
if where == "R" or where == "L" then
if hr > 9 then
-- [L] HHH:MM:S
-- [R] HHH.MM:S
Output = string.format("%3d.%02d%s%d", hr, mn, colon, sc/10)
elseif hr > 0 then
if where == "R" then
-- [R] H:MM.SS.m
Output = string.format("%d:%02d%s%02d.%d", hr, mn, sc, cs/10)
else
-- [L] H.MM:SS.m
Output = string.format("%d.%02d:%02d.%d", hr, mn, sc, cs/10)
end
elseif mn > 0 then
-- MM.SS.m
Output = string.format(" %2d.%02d.%d", mn, sc, cs/10)
else
-- SS.mmm
Output = string.format(" %2d.%03d", sc, ms)
end
else
if hr > 0 then
-- HHh
Output = string.format("%2dh", hr)
elseif mn > 9 then
if where ~= "Rl" then
-- MM.S
Output = string.format("%2d%s%d", mn, dot, sc/10)
else
-- MM'
Output = string.format("%2d%s", mn, min)
end
elseif mn > 0 then
if where ~= "Lr" then
-- M.SS
Output = string.format("%d.%02d", mn, sc)
else
-- M:S
Output = string.format(" %d%s%d", mn, colon, sc)
end
else
if where ~= "Rl" then
-- SS.m
Output = string.format("%2d.%d", sc, cs/10)
else
if sc > 9 then
-- SS
Output = string.format(" %2d", sc)
else
-- S.mm
Output = string.format("%d.%02d", sc, cs)
end
end
end
end
else
-- splittimes --
if hr > 0 then
-- -HHhMM
Output = string.format("%3dh%02d", hr, mn)
elseif mn > 0 then
-- -MM.SS.m
Output = string.format("%3d.%02d.%d", mn, sc, cs/10)
else
-- -SS.mmm
Output = string.format("%3d.%03d", sc, ms)
end
end
else
if splitTime == false then
-- 0.0.0:00:0 [0.] 0:00.0.0:0 --
if where == "R" then
Output = "-:--.---"
elseif where == "L" then
Output = " -:--.-"
else
if where ~= "Rl" then
Output = "--.-"
else
Output = "-.--"
end
end
else
-- 0.0.0:00:0 [0.] 0:00.0.0:0 --
if where == "R" or where == "L" then
Output " --.---"
else
if where ~= "Rl" then
Output "--.-"
else
Output "-.--"
end
end
end
end
ticks = GetTicks()
if mDebug ==nil or ticks < mDebug then
if time == nil then time = "NIL" end
if Output == nil then Output = "NIL" end
print ( time .. " [" .. where .. "] " .. Output )
mDebug = ticks + 10000
end
return Output
end
print ( "gugus> + switch positions" )
|