summaryrefslogtreecommitdiff
path: root/scripts/slipro_digits.lua
blob: f49080fa129bc2506bba34fc48f03f0168bc1510 (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
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
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
-- SLIPRO Lua Script v3.3.2
-- Copyright (c)2012-2013 by Zappadoc - All Rights Reserved.
-- this script builds all functions associated with
-- left and right panels of SLIPRO device
-- last change by Zappadoc - 2013-09

-- ============================================================
-- Left and Right Panel functions
-- ============================================================

-- IN function of left panel
-- param: recieve from SLI Manager the current switch position
function leftDigitsEvent(swFunction)
	swValue = swFunction + 1
	-- call custom script
	local result = custom_leftDigitsEvent(swValue)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	-- call global custom script
	result = global_custom_leftDigitsEvent(swValue)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	local lPanel = ""
	local inf = ""
	local unit = false
	local spd = 0.0
	-- get speed in kph or mph (use "rawspeed" to get value in meter/sec)
	local spd = GetCarInfo("speed")
	-- get current display unit metric or imperial
	unit = GetContextInfo("speedmetric")
	-- check if quick info button is down
	local qi = false
	qi = GetContextInfo("quickinfobutton")
	if qi == nil or qi == 0 then qi = false end
	if qi then
		-- get index for left panel
		local qiLeft = GetContextInfo("quickinfoleft")
		if qiLeft == nil then qiLeft = 1 end
		-- force position to match QI preference
		swValue = qiLeft
	end

	-- check if PIT Feedback ON
	local pf = false
	pf = GetContextInfo("pitfeedback")
	if pf == nil or pf == 0 then pf = false end
	if pf then
		-- force position to PIT/SPEED function if car pits
		local pit = GetCarInfo("inpits")
		if pit > 0 then
			swValue = 35
		end
	end

	-- get current simulation name
	local sim = GetContextInfo("simulation")

	--print ( "swValue: " .. swValue .. "\n")

	-- check postion and compute left panel string
	if swValue == 1 then
		-- speed only
		lPanel = string.format("   %3.0f", spd )

	elseif swValue == 2 then
		-- fuel:speed
		local fuel = GetCarInfo("fuel")
		if fuel ~= nil then
			fuel = GetFuel(fuel, unit)
			if fuel >= 100 then
				-- special case for Euro Truck :)
				lPanel = string.format("%03d:%3.0f", round(fuel)%1000, spd)
			elseif fuel >= 10 then
				lPanel = string.format("F%02d:%3.0f", round(fuel), spd)
			elseif fuel >= 1 then
				lPanel = string.format("F%1.1f:%3.0f", fuel, spd)
			else
				lPanel = string.format("F.%2d:%3.0f", fuel * 100, spd)
			end
		end
	elseif swValue == 3 then
		-- position:speed
		inf = GetContextInfo("position")
		if inf ~= nil then
			if inf >= 100 then
				lPanel = string.format("%03d:%3.0f", inf, spd)
			else
				lPanel = string.format("P%02d:%3.0f", inf, spd)
			end
		end
	elseif swValue == 4 then
		-- laps completed:speed
		inf = GetContextInfo("laps")
		if inf ~= nil then
			-- if more than 99 laps
			if inf >= 100 then
				lPanel = string.format("%03d:%3.0f", inf, spd)
			else
				lPanel = string.format("L%02d:%3.0f", inf, spd)
			end
		end
	elseif swValue == 5 then
		-- sector:speed
		inf = GetCarInfo("sector")
		if inf ~= nil then
			-- check if sector > 9
			if inf >9 then
				lPanel = string.format("S%02d:%3.0f", inf, spd)
			else
				lPanel = string.format("S%01d :%3.0f", inf, spd)
			end
		end
	elseif swValue == 6 then
		-- laps completed:total laps if available
		inf = GetContextInfo("laps")
		if inf ~= nil then
			local tl = GetContextInfo("lapscount")
			if tl < 1 then  tl = 0 end
			-- if more than 99 laps
			if inf >= 100 or tl >= 100 then
				lPanel = string.format("%03d:%03d", inf, tl)
			else
				lPanel = string.format("L%02d:t%02d", inf, tl)
			end
		end
	elseif swValue == 7 then
		-- water temp
		inf = GetCarInfo("watertemp")
		if inf ~= nil then
			inf = GetTemp(inf, unit)
			lPanel = string.format("H2o:%2.1f", inf)
		end
	elseif swValue == 8 then
		-- oil temp
		inf = GetCarInfo("oiltemp")
		if inf ~= nil then
			inf = GetTemp(inf, unit)
			lPanel = string.format("OIL:%2.1f", inf)
		end

	elseif swValue == 9 then
		-- wheels temp if available
		inf = GetCarInfo("wheeltempfrontleft")
		if inf ~= nil then
			-- if rFactor convert Kelvin to Celsius (see global.lua)
			if isAppRFactor(sim) then  inf = KtoC(inf) end
			lPanel = string.format("tFL:%3.0f", inf)
		end
	elseif swValue == 10 then
		inf = GetCarInfo("wheeltempfrontright")
		if inf ~= nil then
			if isAppRFactor(sim) then  inf = KtoC(inf) end
			lPanel = string.format("tFr:%3.0f", inf)
		end
	elseif swValue == 11 then
		inf = GetCarInfo("wheeltemprearleft")
		if inf ~= nil then
			if isAppRFactor(sim) then  inf = KtoC(inf) end
			lPanel = string.format("trL:%3.0f", inf)
		end
	elseif swValue == 12 then
		inf = GetCarInfo("wheeltemprearright")
		if inf ~= nil then
			if isAppRFactor(sim) then  inf = KtoC(inf) end
			lPanel = string.format("trr:%3.0f", inf)
		end

	elseif swValue == 13 then
		-- wheels pressure if available
		inf = GetCarInfo("wheelpressfrontleft")
		if inf ~= nil then
			-- convert to psi
			lPanel = string.format("PFL:%2.1f", inf / 6.88)
		end
	elseif swValue == 14 then
		inf = GetCarInfo("wheelpressfrontright")
		if inf ~= nil then
			lPanel = string.format("PFr:%2.1f", inf / 6.88)
		end
	elseif swValue == 15 then
		inf = getcarinfo("wheelpressrearleft")
		if inf ~= nil then
			lpanel = string.format("prl:%2.1f", inf / 6.88)
		end
	elseif swValue == 16 then
		inf = GetCarInfo("wheelpressrearright")
		if inf ~= nil then
			lPanel = string.format("Prr:%2.1f", inf / 6.88)
		end

	elseif swValue == 17 then
		-- brakes temp if available
		inf = GetCarInfo("braketempfrontleft")
		if inf ~= nil then
			if isAppRFactor(sim) or sim == "GTR2.exe" then  inf = KtoC(inf) end
			lPanel = string.format("BFL:%3.0f", inf)
		end
	elseif swValue == 18 then
		inf = GetCarInfo("braketempfrontright")
			if inf ~= nil then
			if isAppRFactor(sim) or sim == "GTR2.exe" then  inf = KtoC(inf) end
			lPanel = string.format("BFr:%3.0f", inf)
		end
	elseif swValue == 19 then
		inf = GetCarInfo("braketemprearleft")
		if inf ~= nil then
			if isAppRFactor(sim) or sim == "GTR2.exe" then  inf = KtoC(inf) end
			lPanel = string.format("BrL:%3.0f", inf)
		end
	elseif swValue == 20 then
		inf = GetCarInfo("braketemprearright")
		if inf ~= nil then
			if isAppRFactor(sim) or sim == "GTR2.exe" then  inf = KtoC(inf) end
			lPanel = string.format("Brr:%3.0f", inf)
		end
	elseif swValue == 21 then
		-- position
		local pos = GetContextInfo("position")
		lPanel = string.format("  P%02d ",  pos )

	elseif swValue == 22 then
		-- get an average consumption of fuel per lap and gives the remaining laps
		local remainlapsintank = GetCarInfo("remainlapsintank")
		lPanel = string.format(" FL%3.0f", math.floor(remainlapsintank)  )

	elseif swValue == 23 then
		-- rpm
		local rpm = GetCarInfo("rpm")
		lPanel =  string.format(" %5d", rpm)

	elseif swValue == 24 then
		-- track size
		local trcksz = GetContextInfo("tracksize")
		lPanel =  string.format("%5d ", trcksz)

	elseif swValue == 25 then
		-- 25.fuel:consumption
		local fuel = GetCarInfo("fuel")
		local remainlapsintank = GetCarInfo("remainlapsintank")

		local sFuel = "   "
		local sRemainLaps = "   "

		if fuel ~= nil then
			fuel = GetFuel(fuel, unit)
			if fuel >= 100 then
				-- specific for euro truck :)
				sFuel = string.format("%03d", round(fuel) % 1000 )
			elseif fuel >= 10 then
				sFuel = string.format("F%02d", round(fuel) )
			elseif fuel >= 1 then
				sFuel = string.format("F%1.1f", fuel )
			else
				sFuel = string.format("F.%02d", fuel * 100 )
			end

			if remainlapsintank == 0 then
				sRemainLaps = "   "
			elseif remainlapsintank >= 100 then
				sRemainLaps = ":L99"
			elseif remainlapsintank >= 10 then
				sRemainLaps = string.format(":L%2d", math.floor(remainlapsintank))
			else
				sRemainLaps = string.format(":L%1.1f", remainlapsintank)
			end

			lPanel = string.format("%s%s", sFuel, sRemainLaps)
		end

	elseif swValue == 26 then
		-- 26.distance
		local dist = GetContextInfo("lapdistance")
		lPanel = string.format("%5.0f", dist )

	elseif swValue == 27 then
		--27.lap completed
		local laps = GetContextInfo("laps")
		lPanel = string.format(" L%3.0f ", laps )

	elseif swValue == 28 then
		--28.total laps
		local lpcnt = GetContextInfo("lapscount")
		lPanel = string.format("  t%3d", lpcnt )

	elseif swValue == 29 then
		--29.sector
		local sect = GetCarInfo("sector")
		-- check if sector > 9
		if sect >9 then
			lPanel = string.format("  S%02d ", sect)
		else
			lPanel = string.format("  S%01d  ", sect)
		end

	elseif swValue == 30 then
		--30.kers
		local kers = GetCarInfo("kers")
		lPanel = string.format("  E:%3d", round(kers/1000))

	elseif swValue == 31 then
		--31.kers max
		local kmx = GetCarInfo("kersmax")
		lPanel = string.format("  E:%03d", round(kmx/1000))

	elseif swValue == 32 then
		--32.drs
		local drs = GetCarInfo("drs")
		if drs == 1 then
			lPanel = "DrS:ON "
		else
			lPanel = "DrS:OFF"
		end

	elseif swValue == 33 then
		--33.kers percent
		local kers = GetCarInfo("kers")
		lPanel = string.format("  E:%3d", round((kers/1000)/4))

	elseif swValue == 34 then
		--33.kers percent:speed
		local kers = GetCarInfo("kers")
		lPanel = string.format("%3d:%3.0f", round((kers/1000)/4), spd)

	elseif swValue == 35 then
		-- PIT
		lPanel = "  PIt "

	elseif swValue == 36 then
		-- sc
		local sc = GetContextInfo("safetycar")
		if sc == 1 then
			lPanel = "SaFETy"
		else
			lPanel = "      "
		end

	else
		lPanel = "-:--.---"
	end
	-- send string to sli manager
	SetLeftDigits( lPanel )
	return 1
end

-- IN function of right panel
-- param: recieve from SLI Manager the current switch position
function rightDigitsEvent(swFunction)
	swValue = swFunction + 1
	-- call custom script
	local result = custom_rightDigitsEvent(swValue)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	-- call global custom script
	result = global_custom_rightDigitsEvent(swValue)
	-- if result = 0 bypass the script below and return 0
	-- if result = 1 bypass the script below and return 1
	if result <= 1 then return result end
	-- if result >= 2 continue

	local hr = 0
	local mn = 0
	local sc = 0
	local ms = 0
	local hd = 0
	local rPanel = ""
	local lpt = 0.0
	local diffFlag = false
	local unit = false

	-- is OSP Tracking ON
	local ospt = false
	ospt = GetContextInfo("osptracking")
	if ospt == nil then ospt = false end
	if ospt then
		swValue = 23
	end

	-- lap finished, display lap time a few seconds
	local dlt = false
	dlt = GetContextInfo("displaylaptime")
	if dlt == nil then dlt = false end
	if dlt and swValue ~= 37 and swValue ~= 38 then
		swValue = 3
	end

	-- check if quick info button is down
	local qi = false
	qi = GetContextInfo("quickinfobutton")
	if qi == nil or qi == 0 then qi = false end
	if qi then
		-- get index for right panel
		local qiRight = GetContextInfo("quickinforight")
		if qiRight == nil then qiRight = 1 end
		swValue = qiRight
	end
	-- get current display unit metric or imperial
	unit = GetContextInfo("speedmetric")

	-- check if PIT Feedback ON
	local pf = false
	pf = GetContextInfo("pitfeedback")
	if pf == nil or pf == 0 then pf = false end
	if pf then
		-- force position to SPEED function
		local pit = GetCarInfo("inpits")
		if pit > 0 then
			swValue = 20
		end
	end

	--print ( "swValue: " .. swValue .. "\n")

	-- get sim name
	local sim = GetContextInfo("simulation")
	if sim ~= nil then
		if swValue == 1 then
			-- current lap time
			lpt = GetTimeInfo("laptime")
		elseif swValue == 2 then
			-- best lap time (PB)
			lpt = GetTimeInfo("bestlaptime")
		elseif swValue == 3 then
			-- last lap time
			lpt = GetTimeInfo("lastlaptime")

		elseif swValue >= 4 and swValue <= 10 and isAppIRacing(sim) then
			-- iRacing partials
			local ts = GetContextInfo("partialcount")
			local sector = GetCarInfo("sector")
			if ts ~= nil and ts > 0 then
			if swValue == 4 then
			lpt = GetPartialTimeInfo("currentpartial", sector)
			elseif swValue == 5 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vsbestlap", sector)
			elseif swValue == 6 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vsoptimallap", sector)
			elseif swValue == 7 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vsoptimalsector", sector)
			elseif swValue == 8 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vssessionbestlap", sector)
			elseif swValue == 9 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vssessionoptimallap", sector)
			elseif swValue == 10 then
			diffFlag = true
			lpt = GetPartialTimeInfo("vssessionoptimalsector", sector)
			end
			else
			lpt = 0.0
			end

		elseif swValue == 11 then
			-- real time diff vs your best
			diffFlag = true
			lpt = GetTimeInfo("realdiffbest")

		elseif swValue == 12 then
			-- real time diff vs your last
			diffFlag = true
			lpt = GetTimeInfo("realdifflast")

		elseif swValue == 13 then
			-- current sector
			local sector = GetCarInfo("sector")
			local lt = GetTimeInfo("laptime")
			if sector == 1 then
			lpt = lt
			elseif sector == 2 then
			local s1 = GetTimeInfo("lastsector1")
			lpt = lt - s1
			else
			-- sector 3
			local s1 = GetTimeInfo("lastsector1")
			local s2 = GetTimeInfo("lastsector2")
			lpt = lt - (s1 + s2)
			end
		elseif swValue == 14 then
			-- best sector 1
			lpt = GetTimeInfo("bestsector1")
		elseif swValue == 15 then
			-- best sector 2
			lpt = GetTimeInfo("bestsector2")
		elseif swValue == 16 then
			-- last sector 1
			lpt = GetTimeInfo("lastsector1")
		elseif swValue == 17 then
			-- last sector 2
			lpt = GetTimeInfo("lastsector2")
		elseif swValue == 18 then
			-- position
			local pos = GetContextInfo("position")
			if pos >= 100 then
			rPanel = string.format(" P%03d ",  pos )
			else
			rPanel = string.format("  P%02d ",  pos )
			end
			SetRightDigits( rPanel )
			return 1
		elseif swValue == 19 then
			-- get an average consumption of fuel per lap and gives the remaining laps
			local remainlapsintank = GetCarInfo("remainlapsintank")
			rPanel = string.format(" FL%3.0f", math.floor(remainlapsintank)  )

		elseif swValue == 20 then
			-- speed on right panel
			local spd = GetCarInfo("speed")
			rPanel = string.format("  %3d ", spd )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 21 then
			-- time remaining if available
			lpt = GetTimeInfo("timeremaining")

			-- explod time
			hr, mn, sc, hd, ms = timeDispatcher(lpt)
			if hr == 0 then
			if mn <= 10 then
			rPanel =  string.format( "  %1d.%02d.%1d", mn, sc, ms)
			else
			rPanel =  string.format( " %2d.%02d.%1d", mn, sc, ms)
			end
			elseif hr < 10 then
			rPanel =  string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
			else
			rPanel =  string.format( " %02d.%02d.%1d", hr, mn, sc)
			end
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 22 then
			-- PC system time
			lpt = GetTimeInfo("systemtime")
			-- explod time
			hr, mn, sc, hd, ms = timeDispatcher(lpt)
			rPanel =  string.format( " %02d.%02d ", hr, mn)
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 23 then
			-- rpm:gear
			local rpm = GetCarInfo("rpm")
			if rpm == nil then
			return 1
			end
			local gear = GetCarInfo("gear")
			if gear ~= nil then
			rPanel =  string.format("%5d:%d", rpm, gear)
			SetRightDigits( rPanel )
			end
			return 1

		elseif swValue == 24 then
			-- time elapsed if available
			local lpt = GetTimeInfo("timetotalelapsed")

			-- explod time
			hr, mn, sc, hd, ms = timeDispatcher(lpt)
			if hr == 0 then
			if mn <= 10 then
			rPanel =  string.format( "  %1d.%02d.%1d", mn, sc, ms)
			else
			rPanel =  string.format( " %2d.%02d.%1d", mn, sc, ms)
			end
			elseif hr < 10 then
			rPanel =  string.format( "%1d:%02d.%02d.%1d", hr, mn, sc, ms)
			else
			rPanel =  string.format( " %02d.%02d.%1d", hr, mn, sc)
			end
			SetRightDigits( rPanel )
			return 1
		elseif swValue == 25 then
			-- 25.fuel
			local fuel = GetCarInfo("fuel")
			if fuel ~= nil then
			fuel = GetFuel(fuel, unit)
			if fuel >= 100 then
			rPanel = string.format(" F%03d ", round(fuel))
			elseif fuel >= 10 then
			rPanel = string.format(" F%02d  ", round(fuel))
			else
			rPanel = string.format(" F%1.1f  ", fuel)
			end

			SetRightDigits( rPanel )
			return 1
			end

		elseif swValue == 26 then
			-- 26.distance
			local dist = GetContextInfo("lapdistance")
			rPanel = string.format(" %5d", dist )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 27 then
			--27.lap completed
			local laps = GetContextInfo("laps")
			rPanel = string.format("  %3d ", laps )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 28 then
			--28.total laps
			local lpcnt = GetContextInfo("lapscount")
			rPanel = string.format("  %3d ", lpcnt )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 29 then
			--29.sector
			local sect = GetCarInfo("sector")
			-- check if sector > 9
			if sect >9 then
			rPanel = string.format(" S%02d  ", sect)
			else
			rPanel = string.format(" S%01d   ", sect)
			end
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 30 then
			--30.kers
			local kers = GetCarInfo("kers")
			rPanel = string.format(" E%03d ", round(kers/1000) )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 31 then
			--31.kers max
			local kmx = GetCarInfo("kersmax")
			rPanel = string.format(" E%03d ", round(kmx/1000) )
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 32 then
			--32.drs
			rPanel = "DrS.OFF"
			local drs = GetCarInfo("drs")
			if drs >= 1 then
			rPanel = "DrS. ON"
			end
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 33 then
			--33.kers percent
			local kers = GetCarInfo("kers")
			rPanel = string.format(" %3d  ", round((kers/1000)/4))
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 34 then
			--34 track size
			local trcksz = GetContextInfo("tracksize")
			rPanel =  string.format("%5d ", trcksz)
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 35 then
			--35 last sector 1, 2 and 3
			local sector = GetCarInfo("sector")
			if sector == 1 then
			-- sector 3
			local ls1 = GetTimeInfo("lastsector1")
			local ls2 = GetTimeInfo("lastsector2")
			local lt = GetTimeInfo("lastlaptime")
			if ls1 > 0 and ls2 > 0 then
			lpt = lt - (ls1 + ls2)
			end
			elseif sector == 2 then
			local ls1 = GetTimeInfo("lastsector1")
			lpt = ls1
			else
			-- sector 3
			local ls2 = GetTimeInfo("lastsector2")
			lpt = ls2
			end

		elseif swValue == 36 then
			--36.rpm
			local rpm = GetCarInfo("rpm")
			rPanel =  string.format("%5d ", rpm)
			SetRightDigits( rPanel )
			return 1

		elseif swValue == 37 then
			-- real time delta vs last + last sector diff 1, 2 and 3
			local sector = GetCarInfo("sector")
			diffFlag = true
			if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
			-- 8s delay, increase it if needed
			mDiffSectorDelay = GetTicks() + 8000
			mDiffOldSector = sector
			end
			-- init backup vars
			if mOld_lt == nil then
			mOld_ls1 =  0.00000
			mOld_ls2 =  0.00000
			mOld_lt =  0.00000
			mDelta_lpt = 0.00000
			mDelta_lptb = 0.00000
			end

			-- display delta by default
			lpt = GetTimeInfo("realdifflast")

			if mDiffSectorDelay > GetTicks() then
			-- display sector
			if sector == 1  then
			-- sector 3
			local lt = GetTimeInfo("lastlaptime")

			-- if ls1 > 0 and ls2 > 0 and lt > 0 and mOld_ls1 > 0 and mOld_ls2 > 0 and mOld_lt > 0 then
			-- delta sector 3
			--lpt = (lt - (ls1 + ls2)) -  (mOld_lt - (mOld_ls1 + mOld_ls2))
			if lt > 0 and mOld_lt > 0 then
			if lt ~= mOld_lt then
			mDelta_lpt = lt - mOld_lt
			print(mDelta_lpt, lt, mOld_lt)
			end
			lpt = mDelta_lpt
			end

			mOld_lt =  lt


			elseif sector == 2 then
			-- sector 1
			local ls1 = GetTimeInfo("lastsector1")
			if ls1 > 0 and mOld_ls1 > 0 then
			lpt = ls1 - mOld_ls1
			end
			mOld_ls2 = GetTimeInfo("lastsector2")
			print(lpt, ls1 , mOld_ls1, mOld_ls2)

			else
			-- sector 2
			local ls2 = GetTimeInfo("lastsector2")
			if ls2 > 0 and mOld_ls2 > 0 then
			lpt =  ls2 - mOld_ls2
			end
			mOld_ls1 = GetTimeInfo("lastsector1")
			print(lpt, ls2 , mOld_ls1, mOld_ls2)
			end
			end

		elseif swValue == 38 then
		-- real time delta vs best + best sector diff 1, 2 and 3

		-- get sector
		local sector = GetCarInfo("sector")
		-- set flags
		diffFlag = true

		-- set delay
		if mDiffSectorDelay == nil or mDiffOldSector == nil or mDiffOldSector ~= sector then
			-- 8s delay, increase it if needed
			mDiffSectorDelay = GetTicks() + 8000
			mDiffOldSector = sector
		end

		-- init backup vars
		if mOld_bt == nil then
			mOld_bs1 =  0.00000
			mOld_bs2 =  0.00000
			mOld_bt =  0.00000
			mDelta_lpt = 0.00000
			mDelta_lptb = 0.00000
		end

		-- display delta by default
		lpt = GetTimeInfo("realdiffbest")

		if mDiffSectorDelay > GetTicks() then
			-- display sector diff during delay
			if sector == 1  then
				-- sector 3
				local bt = GetTimeInfo("bestlaptime")

				--if bs1 > 0 and bs2 > 0 and bt > 0 and mOld_bs1 > 0 and mOld_bs2 > 0 and mOld_bt > 0 then
				-- delta sector 3
				-- lpt = (bt - (bs1 + bs2)) - (mOld_bt - (mOld_bs1 + mOld_bs2))
				if bt > 0 and mOld_bt > 0 then
					if bt ~= mOld_bt then
						mDelta_lptb = bt - mOld_bt
						print(mDelta_lpt, bt, mOld_bt)
					end
					lpt = mDelta_lptb
				end

				mOld_bt =  bt

				elseif sector == 2 then
					-- sector 1
					local bs1 = GetTimeInfo("bestsector1")
					if bs1 > 0  and mOld_bs1 > 0 then
						lpt =  bs1 - mOld_bs1
					end
					print(lpt, bs1 )
					mOld_bs2 =  GetTimeInfo("bestsector2")

				else
					-- sector 2
					local bs2 = GetTimeInfo("bestsector2")
					if bs2 > 0  and mOld_bs2 > 0 then
						lpt = bs2 - mOld_bs2
					end
					print(lpt, bs2 )
					mOld_bs1 =  GetTimeInfo("bestsector1")
				end
			end

		else
			-- none
			rPanel = "-:--.---"
			SetRightDigits( rPanel )
			return 1
		end
	end

	if lpt == nil then return 0 end

	local refreshRate = mRefreshLapTimeRate
	if diffFlag then
		refreshRate = mDeltaTimeDelay
	end

	-- check if diff time is ready
	local diffOK = GetTimeInfo("realdifftimeready")
	if diffFlag and diffOK == false then
		diffFlag = false
		rPanel = "  -.---"

		mOld_ls1 =  0.00000
		mOld_ls2 =  0.00000
		mOld_lt =  0.00000
		mDelta_lpt = 0.00000
		mDelta_lptb = 0.00000

		SetRightDigits( rPanel )
		return 1
	end

	local c = " "
	if lpt < 0 then
		c = "-"
	end
	-- explod time
	hr, mn, sc, hd, ms = timeDispatcher(lpt)

	-- print("lpt: " .. lpt .. " m: " .. mn .. " - s: " .. sc .. " - ms: " .. ms .. )
	if GetTicks() > ( refreshRate + mDeltaTimeOldTicks ) then
		mDeltaTimeOldTicks = GetTicks()

		if diffFlag then
			--
			if lpt == -1 or (mn + sc + ms) == 0.0000 then
				mDeltaTimeBackup =  " --.---"
			elseif mn > 0 then
				mDeltaTimeBackup =  string.format( "%s%2d.%02d.%01d", c, mn, sc, ms)
			else
				mDeltaTimeBackup =  string.format( "%s%2d.%03d", c, sc, ms)
			end

			rPanel = mDeltaTimeBackup

		else
			--if mTimeBackup == nil then mTimeBackup = 0.0000 end
			if lpt == -1 or (mn + sc + ms) == 0.0000 then
				mDeltaTimeBackup =  "-:--.---"
			elseif mn < 10 then
				mDeltaTimeBackup =  string.format( "%1d:%02d.%03d", mn, sc, ms)
			elseif hr > 0 then
				mDeltaTimeBackup =  string.format( " %02d.%02d ", hr, mn)
			else
				mDeltaTimeBackup =  string.format( " %02d.%02d.%01d", mn, sc, ms)
			end

		end
	end
	rPanel = mDeltaTimeBackup
	-- send time to sli manager
	SetRightDigits( rPanel )
	return 1
end