summaryrefslogtreecommitdiff
path: root/scripts/slimax_script_readme.txt
blob: 8e5fc44962bdf8921ed944e5841ab626ffbf3561 (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
SLIMax Manager II 2.2.4.5 Scripting Information - PART OF SLIMax Manager pkg
Copyright (c)2011-2013 by EK & Zappadoc - All Rights Reserved.
updated 2013-01-16 by Zappadoc

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

=================================
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
0 (zero) to skip and give control to SLIMax Mgr

---------------------------------------------
function shiftLightsMethodEvent(idx) and custom_shiftLightsMethodEvent
function shiftLightsBU0710Event(idx) and custom_shiftLightsBU0710Event
param = current method index
Notes: shiftlights method event, computes all shiftlights methods
(see shiftlights.lua script)

---------------------------------------------
function ospMethodEvent(idx) and custom_ospMethodEvent
param = current method index
Notes: OSP method event, computes all Optimal Shift-Points methods
(see osp.lua script)

---------------------------------------------
function spdLmtMethodEvent(idx) and custom_spdLmtMethodEvent
param = current method index
Notes: speedlimiter method event, computes all speedlimiter methods
(see speedlimiter.lua script)

---------------------------------------------
function leftDigitsEvent(swPosition) and custom_leftDigitsEvent
function rightDigitsEvent(swPosition) and custom_rightDigitsEvent
param = switch position
Notes: SLI-PRO Left and Right Panel functions events, computes data to be
displayed on left and rights digits of SLI-PRO device
(see slipro.lua script)

---------------------------------------------
function controlsEvent(deviceIdx, ctrlType, ctrlPos, value, funcIndex) and custom_controlsEvent
params = see the script
Notes: Controls Event, Manage buttons and switches. (see controls.lua script)

---------------------------------------------
function deviceReport(devType) and custom_deviceReport
param = the current targeted SLI device
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 gearEvent(gear) and custom_gearEvent
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 enterSessionEvent(devType) and custom_enterSessionEvent
param = current device (SLI-M, SLI-PRO or BU0710)
Notes: Triggered when the session starts
(see enter_exit_session.lua script)

---------------------------------------------
function exitSessionEvent(devType) and custom_exitSessionEvent
param = current device (SLI-M, SLI-PRO or BU0710)
Notes: Triggered when the session ends
(see enter_exit_session.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
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
============================================

---------------------------------------------
SetBU0710Led(int)
param integer = number from 0 to 10
set leds of BU0710 device (e.g. 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 (e.g. 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 (e.g. 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)

---------------------------------------------
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)

---------------------------------------------
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 DIGITS ==========
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 script)

---------------------------------------------
SetDigitsAllowed(boolean)
param boolean = true or false
by default the 6 + 6 SLI-PRO 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)
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
This function is experimental and unsupported

SPECIAL KEYCODE TABLE:
 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)

-----------------------------------------------------------------------------------
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 )

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

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

-----------------------------------------------------------------------------------
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

"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 mDeviceType global)
"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)

-----------------------------------------------------------------------------------
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
"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
"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
"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
"bestsector1" return best sector 1 if available
"bestsector2" return best sector 2 if available
"lastsector1" return last sector 1 if available
"lastsector2" 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
(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 NOT AVAILABLE IN ALL SIMULATIONS ** IMPORTANT

"currentpartial" return current partial time if available
"bestpartial" return best partial time of this sector if available
"optimalpartial" return optimal partial time of this sector if available
"sessionbest" return session best partial time of this sector
"sessionoptimal" return session optimal partial time of this sector
"diffbestpartial" return diff from best if available
"diffoptimalpartial" return diff from optimal if available
"diffsessionbest" return diff from session best if available
"diffsessionoptimal"  return diff from session 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.

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

===============================
 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

mSpdLimitMethod to overwrite the method value, useful in custom_spdLmtMethodEvent() function to patch the current PIT LIMITER method with another one

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

--------------------------------------------------------
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
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 )

--------------------------------------------------------
LEFT and RIGHT Functions utilities
--------------------------------------------------------

-- 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


-- 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 )