summaryrefslogtreecommitdiff
path: root/scripts/slimax_script_readme.txt
blob: 6a22a4f16b5f7e83835735de1a39af179024968c (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
SLIMax Manager III 3.3.3 Scripting Information - PART OF SLIMax Manager pkg
Copyright (c)2011-2013 by EK & Zappadoc - All Rights Reserved.
updated 2013-11 by Zappadoc

** ALL INFORMATION BELOW ARE SUBJECT TO CHANGE WITHOUT NOTICE **

Go to scripting forum support to get the latest information about SLIMax Manager API:
http://www.eksimracing.com/forum

=================================
Script Engine based on Lua 5.1.4

License for Lua 5.1.4 and later versions
Copyright © 1994–2011 Lua.org, PUC-Rio.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

=================================
Lua website
http://www.lua.org/

Reference manual (v5.1):
http://www.lua.org/manual/5.1/


====================================
Events received from SLIMax Manager
====================================

function custom_initEvent(scriptFile)
param = custom script file name
Notes: this event is triggered at startup or when loading your custom script,
this is the good opportunity to init your preferences and global vars

All event functions below must return 1 if the event has been fully managed or
2 to skip and give control to SLIMax Mgr

---------------------------------------------
GLOBAL EVENTS (ALL DEVICES)
---------------------------------------------
function controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex, targetDevice) and custom_controlsEvent
params = see the control.lua script
Devices supported: global event
Notes: Controls Event, Manage buttons and switches. (see controls.lua script)

---------------------------------------------
function deviceReport(deviceType) and custom_deviceReport
param = the current targeted device (BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU)
Devices supported: global event
Notes: This function is called periodically and outputs the previously processed data to the device when it returns
back to the manager, if needed, patch any previous function here to
display additional info or to change everything. (see devhook.lua script)

---------------------------------------------
function enterSessionEvent(deviceType) and custom_enterSessionEvent
param = current device (BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU)
Notes: Triggered when the session starts
(see enter_exit_session.lua script)

---------------------------------------------
function exitSessionEvent(deviceType) and custom_exitSessionEvent
param = current device (BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU)
Devices supported: global event
Notes: Triggered when the session ends
(see enter_exit_session.lua script)

---------------------------------------------
LOCAL EVENTS (SPECIFIC TO DEVICES)
---------------------------------------------
function shiftLightsMethodEvent(idx) and custom_shiftLightsMethodEvent
function shiftLightsBU0710Event(idx) and custom_shiftLightsBU0710Event
function shiftLightsFanatecMethodEvent(idx) and custom_shiftLightsFanatecMethodEvent
function shiftLightsG27LedsMethodEvent(idx) and custom_shiftLightsG27LedsMethodEvent
function shiftLightsSRDlxMethodEvent(idx) and custom_shiftLightsSRDlxMethodEvent
function shiftLightsSRF1MethodEvent(idx) and custom_shiftLightsSRF1MethodEvent
param = current method index
Devices supported: BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU
Notes: shiftlights method event, computes all shiftlights methods
(see shiftlights.lua script)

---------------------------------------------
function ospMethodEvent(idx) and custom_ospMethodEvent
function ospSRDlxMethodEvent(idx) and custom_ospSRDlxMethodEvent
function ospSRF1MethodEvent(idx) and custom_ospSRF1MethodEvent
function ospFanatecMethodEvent(idx) and custom_ospFanatecMethodEvent
function ospG27LedsMethodEvent(idx) and custom_ospG27LedsMethodEvent
param = current method index
Devices supported: BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU
Notes: OSP method event, computes all Optimal Shift-Points methods
(see osp.lua script)

---------------------------------------------
function spdLmtMethodEvent(idx) and custom_spdLmtMethodEvent
function spdLmtSRDlxMethodEvent(idx) and custom_spdLmtSRDlxMethodEvent
function spdLmtSRF1MethodEvent(idx) and custom_spdLmtSRF1MethodEvent
function spdLmtFanatecMethodEvent(idx) and custom_spdLmtFanatecMethodEvent
function spdLmtG27MethodEvent(idx) and custom_spdLmtG27MethodEvent
param = current method index
Devices supported: BU0710, SLI-M, SLI-PRO, SIM RACE Deluxe, SIM RACE F1, Fanatec Wheels and Logitech G27 leds and emulators SLI-EMU and SRF1-EMU
Notes: speedlimiter method event, computes all speedlimiter methods
(see speedlimiter.lua script)

---------------------------------------------
function leftDigitsEvent(swPosition) and custom_leftDigitsEvent
function rightDigitsEvent(swPosition) and custom_rightDigitsEvent
function srdlxLeftDigitsEvent(swPosition) and custom_srdlxLeftDigitsEvent
function srdlxRightDigitsEvent(swPosition) and custom_srdlxRightDigitsEvent
function srf1LeftDigitsEvent(swPosition) and custom_srf1LeftDigitsEvent
function srf1RightDigitsEvent(swPosition) and custom_srf1RightDigitsEvent
function fanatecDigitsEvent(swPosition) and custom_fanatecDigitsEvent
param = switch position
Devices supported: SLI-PRO, SIM RACE Deluxe, SIM RACE F1 and Fanatec Wheels and emulators SLI-EMU and SRF1-EMU

Notes: computes data to be displayed on digits panel of the device
(see scripts: slipro.lua, simracedlx.lua, simracef1.lua and fanatec.lua)

---------------------------------------------
function gearEvent(gear) and custom_gearEvent
function gearFanatecEvent(gear) and custom_gearFanatecEvent
Devices supported: SLI Boards series and Fanatec Wheels
param = current seleted gear ( -1 = reverse, 0 = neutral, 1 ... 7)
Notes: gear event, show the current selected gear on central digit
(see gear.lua script)

---------------------------------------------
function ledEvent(idx, ledFunction, state) and custom_ledEvent
param = index of the led, std state of the led and corresponding function
1=LowFuel
2=TC
3=ABS
4=Green Flag
5=Yellow flag
6=Red Flag
7=Over Heating
8=Damage
9=Pit request
10=Power
11=Rev Limit
12=HeadLights
13=Blue Flag
14=DRS
15=Safe Prefs

Devices supported: SLI Boards series only
Notes: patch std led behaviors (i.e. tc, abs, lowfuel,
 dammage, rev limit, drs, pit request, flags, ... )
IMPORTANT: your script must be optimized as the function is
called several time by second to report all activated leds
(see led.lua script)

-----------------------------------------------
All functions starting with custom_ can created
to change std behaviors and can be associated
with your custom settings.
(see COMBO SETUP in forum)
-----------------------------------------------


============================================
functions to change SLIMax Manager information
============================================

---------------------------------------------
Fanatec additions:
---------------------------------------------
SetFanatecDigitsAllowed(boolean)
param boolean = true or false
by default the 3 digits are showed but sometime we need to temporarily
hide them to set our custom information, pass false to this function to hide digits
and true to show them again

---------------------------------------------
SetFanatecDigits(string)
param string = 3 chars string + dots
Set the alpha-numerical text (including the . delimiter) to the digits panel (see fanatec.lua script)

---------------------------------------------
SetFanatecOneDigit(digit,a,b,c,d,e,f,g,dot)
param digit = from 0 to 2
param a,b,c,d,e,f,g = false or true
param dot = false or true
Set the 7 segments + dot of each digit

---------------------------------------------
SetFanatecCspMotor(power,delay)
param power: from 0 to 100
param delay: from 0 to 1000 ms (1sec max)

SetFanatecWheelMotor(motor,power,delay)
param motor = 0 or 1 (left or right motor )
param power: from 0 to 100
param delay: from 0 to 1000 ms (1sec max)

SetFanatecLed(string table)	<<<<< DEPRECATED use SetRPMLed()
param string = name of lua table (default mRPMLedTable)
set RPM led of Fanatec rim ( see shiftlights.lua script)

SetFanatecGear(gear)	<<<<< DEPRECATED use SetGearDigits()
param string = one char string (i.e. "r" or "n" or "1" ... )
set the gear value in center of the Fanatec digits panel (see fanatec.lua script)

---------------------------------------------
Logitech Additions:
---------------------------------------------
SetG27Led(int)
param integer = number, each bit represent one led from 0 to 0x1F
set leds of G27 device ( see shiftlights.lua script)

---------------------------------------------
SetBU0710Led(int)
param integer = number from 0 to 10
set leds of BU0710 device ( see shiftlights.lua script)

---------------------------------------------
SetGeadDigit(string)
param string = one char string (i.e. "r" or "n" or "1")
set gear digit of current targeted SLI device ( see gear.lua script)

---------------------------------------------
SetRPMLed(string)
param string = name of lua table (default mRPMLedTable)
set RPM led of current targeted SLI device, SLI-M or SLI-PRO or SIM RACE Deluxe ( see shiftlights.lua script)

---------------------------------------------
SetWarnLed(idx, val)
param integer  = index of led from 1 to 6
param integer  = value 1 or 0
set the 6 extra leds of current targeted SLI device (SLI-M or SLI-PRO or SIM RACE Deluxe)

---------------------------------------------
SetExtLed(idx, val)
param integer = index of led from 1 to 5
param integer  = value 1 or 0
set the 5 external leds of current targeted SLI device (SLI-M or SLI-PRO or SIM RACE Deluxe)

---------------------------------------------
SetOSPStatus(boolean)
param boolean = true or false
in Optimal ShiftPoints (OSP) Methods compute your own OSP curve and set
the corresponding OSP state with this function (true or false - see osp.lua script)

---------------------------------------------
========== SLI-PRO or SIM RACE Deluxe DIGITS PANELs ==========
SetRightDigits(string)
SetLeftDigits(string)
param string = 6 chars string + delimiter
set the alpha-numerical text (including the . and : delimiter) to the right
and left digits (see slipro.lua or simracedlx.lua script)

---------------------------------------------
SetDigitsAllowed(boolean)
param boolean = true or false
by default the 6 + 6 SLI-PRO digits or 4 x 4 SIM RACE Deluxe digits are showed but sometime we need to temporarily
hide them to set our custom information, pass false to this function to hide digits
and true to show them again

---------------------------------------------
SetKeystroke(keycode, delay, modifier, modifier2)
param string or integer = the key as a string (see the special keycode table below ) or Microsoft VKey code as integer
param int = the delay from 50 to 1000 ms
param modifier = SHIFT or CONTROL or ALT or ""
param optional modifier2 = SHIFT or CONTROL or ALT or ""

SPECIAL KEYCODE TABLE IN ADDITION TO A...Z CHARS:
 BACKSPACE
 DEL
 INSERT
 PRTSCREEN
 END
 HOME
 SCROLL
 PGDOWN
 PGUP
 PAUSE
 UP
 DOWN
 LEFT
 RIGHT
 F1
 F10
 F11
 F12
 F13
 F14
 F15
 F16
 F2
 F3
 F4
 F5
 F6
 F7
 F8
 F9
 NUMLOCK
 NUMPAD0
 NUMPAD1
 NUMPAD2
 NUMPAD3
 NUMPAD4
 NUMPAD5
 NUMPAD6
 NUMPAD7
 NUMPAD8
 NUMPAD9
 ENTER
 ESC
 TAB
 ARROWUP
 ARROWDOWN
 ARROWLEFT
 ARROWRIGHT

Modifier:

SHIFT
CONTROL
ALT

-----------------------------------------------------------------------------------
TelemetryTools(selector, value)
Param "value" boolean activate or deactivate the function
Param "selector" (string), this string contains the following value:
"dumplastlap" if it's activated it creates a telemetry log after each lap

-----------------------------------------------------------------------------------
SLISleep(ms)

-----------------------------------------------------------------------------------
Force sending report (not recommended)
SLISendReport()
FanatecSendReport() <<<<< DEPRECATED use SLISendReport()
-----------------------------------------------------------------------------------
SetGlobalBrightness(int)

-----------------------------------------------------------------------------------
SetABSBrightLevel(int)

-----------------------------------------------------------------------------------
SetTCBrightLevel(int)

---------------------------------------------
SetMaxGear(int)
param integer = from 4 to 7
Set the number of gears available

---------------------------------------------
SetDeltaTimeDelay(int)
param integer = from 0 to 5000
set interval to update the display for easy reading of time
the deltatime delay is in ms (1000 = 1s )

---------------------------------------------
result = SetSMXGlobal(globalVarName, stringValue)
param globalVarName = ref name to global
param stringValue = value (if you want to store a number convert it to string)
result return = -2 exceed capacity (20 global max); -1 Error; 0 create new record; 1 update new record

---------------------------------------------
result, stringValue = GetSMXGlobal(globalVarName )
param globalVarName = ref name to global
return string in stringValue  or empty
result return =  -1 Error; 0 not found; 1 ok

---------------------------------------------
SMXMessageBox(text, title, buttons_style, icon_style)
param text = message text
param title  (optional) = title of the dialog box
param buttons_style  (optional) = see global.lua or Microsoft MessageBox buttons flags
param icon_style  (optional) = see global.lua or Microsoft MessageBox icon flags

=========================================
functions to get SLI Manager Information
=========================================

GetContextInfo("selector")
GetCarInfo("selector")
GetTimeInfo("selector")
GetPartialTimeInfo("selector", index)
IsSLIFunction("selector", function_index)
GetDeviceType(deviceID)

-----------------------------------------------------------------------------------
GetContextInfo("selector")
returns contextual info (internal function)
Param "selector" (string), this string contains the following value:

IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT

"devicelist" return the coma delimited list of current detected devices IDs (included game controllers)
Reminder regarding device ID: if ID < 40 this is a shiftlight/Digits device; if >=40 this is a game controller

Fanatec additions:
"bypass" return the state of BYPASS preference (see advanced options panel)
"fanatecdigitscount" return the number of digits default = 3
"wheelmotorcount" return the number of wheel motors default = 2
"cspmotorcount" return the number of Clubsport pedals motors default = 1
"fanatecwheeltype" return the type of wheel
"fanatecrimtype" return the type of rim  ( BMW = 1; Formula = 2)
"cspdetected" return true if CSP are present
"gearshock" return state of GEARSHOCK effect preference (see advanced options panel)
"gearshockdelay" return the value in ms of GEARSHOCKDELAY preference (see advanced options panel)
"fanatecdigits" return the current position of digits panel
"fanatecquickinfo" return the current selected quick-info function


"shiftlightsmethod" return current selected method of targeted device
"ospmethod" return current selected method of targeted device
"speedlimitermethod" return current selected method of targeted device
"pitfeedback" return true when car is on pit lane
"ospcustom" return true if an OSP record to the current car has been found
"neutral" return ascii code of neutral char (default 'n')
"reverse" return ascii code of reverse char (default 'r')
"sessiontype" see here: http://www.eksimracing.com/forum/index.php?topic=891.msg4560#msg4560
"ticks" return system tick count (int)
"speedmetric" return display unit true if imperial/MPH and false if metric/KMH
"simulation" return current simulation name (string) if available
"paused" return true if simulation is paused if available
"pluginactive" return 1 if a plugin has been activated
"pluginready" return true if plugin is ready to send data from simulation
"devicetype" return current targeted SLI USB device (integer - see also GetDeviceType())
"tracksize" return current track size (meter) if available
"lapdistance" return the traveled distance of the car (meter) if available
"trackame" return current track name if available
"carname" return current car name if available
"position" return current car position if available
"laps" return laps completed (current lap) if available
"lapscount" return total lap (race) if available
"partialcount" or "sectorcount" number total of partial time
"blinktime" blinking delay (default 32)
"ospblinktime" blinking delay (default 8 )
"spdlmtrpmledonlyflag" rpm leds only when speedlimiter active? (boolean)
"noblinkflag" blinking allowed or not? (boolean)
"limitercharflag" limiter char must be showed? (boolean)
"ledspeedlimiterindex" return the current speedlimiter index (position) led (default 4 of value from 1 to 6)
"displaylaptime" lap time need to be showed or not (boolean)
"quickinfobutton" quick-info button is pressed or not (boolean)
"quickinfoleft" quick-info left panel index (position) function (integer)
"quickinforight" quick-info right panel index (position) function (integer)
"osptracking" osp tracking button activated or not (boolean)
"ospfactor" current osp factor (float)
"ospwithfirstgear" osp at first gear allowed (boolean)
"osplimitrpm" OSP rpm limit, result from my own OSP curve (integer)
"ospled1" OSP led 1 index (position) (integer)
"ospled2"  OSP led 2 index (position) (integer)
"yellowflag" return status of flags
"greenflag"
"redflag"
"blueflag"
"lastgearnorpm" return true if no shiftlights (RPM) on last gear
"rightdigits" return current position of right panel (int)
"leftdigits" return current position of left panel (int)
"globalbrightness" return current global brightness value
"lowfuel" return low fuel status
"dumplastlap" return status of telemetry report (true = activated)
"safetycar" return status of SC (true = ON TRACK ) if available

-----------------------------------------------------------------------------------
GetCarInfo("selector")
returns car info (internal function)
Param "selector" (string), this string contains the following value:

IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT

"ignition" return the ignition state in rFactor2, 0=off 1=ignition 2=ignition+starter
"kers" return kers value
"kers max" return max kers energy
"drs" return ON or OFF status
"brakebiais" return current brake biais status
"rawspeed" return current car speed (meter/sec)
"speed" return current car speed in kph or mph depending the current display unit (metric or imperial)
"gear" return current car gear (-1 reverse; 0 = neutral; 1 = gear1,...)
"maxgear" return the current gear max of engine
"inpits" car is in pitlane? (integer)  0= on track; 1= pit stall area; 2= Approaching Pits (Pit Road)
"rpm" return current car rpm (r/mn)
"redzone" return current max engine rpm

"fuel" return current fuel in tank
"fuelmax" return the max capacity of fuel tank
"fuelperlap" return the consumption of fuel during the previous lap, updated after each lap
"averagefuelperlap" return the average of consumption of fuel during a lap
"remainlapsintank" get an average consumption of fuel per lap and return the remaining laps
"fuelatstart" return the fuel in tank at the beginning of each lap

"watertemp" return water engine temp (celsius)
"oiltemp" return oil engine temp (celsius)
"sector" return current sector (integer)
"abs" return abs level (integer)
"tractioncontrol" return TC level (integer)
"speedlimiter" return spd lmt status (integer)
"headlights"
"overheating"
"detachedparts" return true if car is damaged

"wheeltempfrontleft", return front left average temp (celsius)
"wheeltempfrontright", return front right average temp (celsius)
"wheeltemprearleft", return rear left average temp (celsius)
"wheeltemprearright", return rear right average temp (celsius)

"wheelpressfrontleft", return front left average pressure (kpa)
"wheelpressfrontright", return front right average pressure (kpa)
"wheelpressrearleft", return rear left average pressure (kpa)
"wheelpressrearright", return rear right pressure (kpa)

"braketempfrontleft", return front left temp (celsius)
"braketempfrontright", return front right temp (celsius)
"braketemprearleft", return rear left temp (celsius)
"braketemprearright", return rear right temp (celsius)

-----------------------------------------------------------------------------------
GetTimeInfo("selector")
returns time info (internal function)
Param "selector" (string), this string contains the following value:
return float value

IMPORTANT ** THESE VALUES ARE NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT

"laptime" return current lap time if available
"bestlaptime" return best lap time if available
"lastlaptime" return last lap time if available
"realdifftimeready" return true when telemetry data of at least one lap has been collected if available
"realdiffbest" return  real-time diff (delta) vs best  if available
"realdifflast" return real-time diff (delta) vs last  if available
"sector1" return current sector 1 if available
"sector2" return current sector 2 if available
"sector3" return current sector 2 if available
"bestsector1" return best sector 1 if available
"bestsector2" return best sector 2 if available
"bestsector3" return best sector 2 if available
"lastsector1" return last sector 1 if available
"lastsector2" return last sector 2 if available
"lastsector3" return last sector 2 if available
"timeremaining" return session time remaining if available
"systemtime" return current PC time if available

-----------------------------------------------------------------------------------
GetPartialTimeInfo("selector", index)
returns partial time info of iRacing Simulation
(internal function)
Param index (number) contains the targeted sector
Param "selector" (string), contains the following value:
return float value
see GetContextInfo() to get the total number of partials

IMPORTANT ** THESE VALUES ARE AVAILABLE ONLY IN IRACING SIMULATIONS ** IMPORTANT

"currentpartial" return current partial time if available
"vsbestlap" return best partial time of this sector if available
"vsoptimallap" return optimal partial time of this sector if available
"vssessionbestlap" return session best partial time of this sector
"vsoptimalsector" return session optimal partial time of this sector
"vssessionoptimallap"  return diff from session optimal if available
"vssessionoptimalsector" return diff from optimal if available

-----------------------------------------------------------------------------------
IsSLIFunction("selector", function_index)
returns boolean
(internal function)
return boolean value, true if function name matches the function index
Param index (number) contains the targeted function index returned by controlsEvent()
Param "selector" (string), contains the following value:
see controls.lua scripts for more info.

"fanatecdigits"
"brightness"
"quickinfo"
"speedmetric"
"lastgearnorpm"
"osptracking"
"safeprefs"
"laptimedelay"
"blinktime"
"lowfuel"
"speedlimitermethod"
"shiftlights"
"ospmethod"
"rightdigits"
"leftdigits"
"ospfactor"
"drivingsetup"
"maxgear"

-----------------------------------------------------------------------------------
GetDeviceType(deviceID)
returns the corresponding name of device ID
Param deviceID (integer)
return string value

-----------------------------------------------------------------------------------
GetLedIndex("selector")
returns the corresponding index of the led
Param led function (string) see the list below
return integer value

"speedlimiter"
"osp1"
"osp2"
"lowfuel"
"tractioncontrol"
"abs"
"greenflag"
"yellowflag"
"redflag"
"overheating"
"damage"
"pitrequest"
"power"
"revlimit"
"headlights"
"blueflag"
"drs"
"safeprefs"
"drslegal"

===============================
 Script Developpment
 globals and utilities
===============================

Script Warriors do not reinvent the wheel and keep your script clean, optimized and obviously reuse the standard behaviors if possible ... ;)

-------------
 GLOBALS
-------------
- A great optimization of OSP and Shiftlights scripts with 2 new globals has been added.
gOSPLimit = limit/treshold computed by SLIMax Manager, the default value is set in gear.lua script. This value can be overwritten in your custom script, this way it lets you run the std OSP function (osp.lua) but with your own OSP curve. each gear of each car can have its own values.

gRedZone = the default value is set in gear.lua script. This value can be overwritten in your custom script, this way it let's you run the std Shiftlights function but with your own red zone value. each gear of each car can have its own values.

mLeftSpdLmtText and mRightSpdLmtText contains the default text for left and right digits panel in speedlimiter method 4 and 5 and can be "patched" (replaced with your own text) in custom_spdLmtMethodEvent() function (see custom_scripts.lua file)

mOSPMethod to overwrite the method value, useful in custom_ospMethodEvent() function to patch the current OSP method with another one
mOSPBU0710Method same as above for BU0710
mOSPG27Method same as above for G27
mOSPFanatecMethod same as above for Fanatec
mOSPSRDlxMethod same as above for SIM RACE Deluxe
mOSPSRF1Method same as above for SIM RACE F1

mSpdLimitMethod to overwrite the method value, useful in custom_spdLmtMethodEvent() function to patch the current PIT LIMITER method with another one
mSpdLimitG27Method same as above for G27
mSpdLimitFanatecMethod same as above for Fanatec
mSpdLimitSRDlxMethod same as above for SIM RACE Deluxe
mSpdLimitSRF1Method same as above for SIM RACE F1

mShiftlightsMethodIndex to overwrite the method value, useful in custom_shiftlightsMethodEvent() function to patch the current shiftlights method with another one
mShiftlightsBU0710MethodIndex same as above for BU0710
mShiftlightsG27MethodIndex same as above for G27
mShiftlightsFanatecMethodIndex same as above for Fanatec
mShiftlightsSRDlxMethodIndex same as above for SIM RACE Deluxe
mShiftlightsSRF1MethodIndex same as above for SIM RACE F1

oldGear is useful in custom_gearFanatecEvent() function to patch the current gear value

-----------------------
 SHIFTLIGHTS UTILITIES
-----------------------
shiftlights utilities functions in SLIMax Mananger script API
(see shiftlights.lua for example and usage)

--------------------------------------------------------
shiftlights utilities functions for Fanatec
--------------------------------------------------------
-- shiftlights method from side to center
function SideToCenterFanatec(rpm, redzone, p1, p2, p3, p4 ,p5 )

-- progressive method
function ProgressiveFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9 )

-- alternate yellow, red and blue method
function AlternateFanatec(rpm, redzone, step1, step2, step3)

-- percentage method
function percentageFanatec(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9 )

-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
function RpmFanatec(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9 )

--------------------------------------------------------
shiftlights utilities functions for SLI-M and SLI-PRO
--------------------------------------------------------
-- shiftlights method from side to center
function SideToCenterSLI(rpm, redzone, p1, p2, p3, p4 ,p5 ,p6 ,p7)

-- progressive method
function ProgressiveSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )

-- alternate green, red and blue method
function AlternateSLI(rpm, redzone, step1, step2, step3)

-- percentage method
function percentageSLI(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )

-- fixed rpm method, set rpm for each led (NOT RECOMMENDED)
function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13 )

-- progressive method but with rpm value for eah led (NOT RECOMMENDED)
function ProgressiveFixedSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13)

--------------------------------------------------------
shiftlights utilities functions for BU0710
--------------------------------------------------------
-- progressive method for BU0710
function ProgressiveBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )

-- percentage method for BU0710
function percentageBU0710(rpm, redzone, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )

-- fixed rpm method for BU0710 (NOT RECOMMENDED)
function RpmSLI(rpm, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11 )

--------------------------------------------------------
shiftlights utilities functions for Logitech G27
--------------------------------------------------------
-- progressive method for G27
function ProgressiveG27(rpm, redzone, p1, p2, p3, p4, p5)

-- percentage method for G27
function PercentageG27(rpm, redzone, p1, p2, p3, p4, p5)

-- fixed rpm method for G27 (NOT RECOMMENDED)
function RpmG27(rpm, p1, p2, p3, p4, p5 )

--------------------------------------------------------
-- KERS functions
function GetKersPercent()

--------------------------------------------------------
LEFT and RIGHT Functions utilities for SLI-M and SLI-PRO
--------------------------------------------------------

-- add a function name to left and right functions list
-- typical usage FuncAddName(path, func):
-- on left list:
-- local err = FuncAddName("cfg/sli_left_functions.ecfg", "100.DSII KERS")
-- or right list:
-- local err = FuncAddName("cfg/sli_right_functions.ecfg", "100.DSII KERS")
-- return 1 if ok
-- local err = FuncAddName("cfg/fanatec_digits_functions.ecfg", "100.DSII KERS")
-- return 1 if ok


-- same as above for removing the function name
-- typical usage RemoveFuncName(path, func)
-- return 1 if ok

-- get the index of function
-- typical usage: local idx = FuncGetPrefixIndex("100.DSII KERS")
-- return value > 0 if ok

-- get next function index available
-- typical usage FuncGetNewIndex(path):
-- on left list:
-- local num_available = FuncGetNewIndex("cfg/sli_left_functions.ecfg")
-- or right list:
-- local num_available = FuncGetNewIndex("cfg/sli_right_functions.ecfg")
-- return value >=100 (0 to 99 are reserved )
-- or fanatec list:
-- local num_available = FuncGetNewIndex("cfg/fanatec_digits_functions.ecfg")
-- return value >=100 (0 to 99 are reserved )

--------------------------------------------------------
functions utilities in global.lua
--------------------------------------------------------

-- return KERS value in percent
function GetKersPercent()

-- Init all globals
function InitGlobals()

-- set RPM threshold value in percentage ( SLIMax Manager 2.1 )
function SetRPMPercentValue(index, value)

-- set RPM threshold value ( SLIMax Manager 2.1 )
function SetRPMAbsoluteValue(index, value)

-- get all global preferences set in general_default.sli
function GetSLIMaxInfo()

-- get cpu ticks
function GetTicks()

-- reset table function
function initLedTable(ibl, value)

-- toggle all led state
function toggleAllLed(val)

-- The following function rounds a number
-- lua doesn't return the same rounded value as C/C++
function round(num)

-- The following function calculate hr, mn, sec, hd, ms
-- param: time in meter/sec
function timeDispatcher( tt)

-- return speed in KPH or MPH
function speed(spd, selector)

-- Fahrenheit to Celsius
function FtoC(f)

-- Celsius to Fahrenheit
function CtoF(c)

-- Kelvin to Celsius
function KtoC(k)

-- liters to gallons
function LtoG(liters)

-- gallons to liters
function GtoL(gallons)

-- return fuel in liters or gallons
function GetFuel(fl, selector)

-- return celcius or fahrenheit
function GetTemp(tmp, selector)

-- set delta time delay in ms
function SetDeltaTimeDelay(delay)

-- force display text on left or/and right panel during delay in ms
function LeftRightMessageText(delay, left_text, right_text)

-- return delta time vs best time + sector diff
-- isRF must be true for rFactor 1 and 2 and clones
function GetDeltaBestTime(isRF)

-- return delta time vs last time + sector diff
-- isRF must be true for rFactor 1 and 2 and clones
function GetDeltaLastTime(isRF)