summaryrefslogtreecommitdiff
path: root/scripts/zdoc_scripts/iracing_stuff.lua
blob: b53c66c4559de609f03372684b69366ebd768406 (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
-- Custom SLIMax Manager Scripts for iRacing v2.1
-- Copyright ©2012-2013 by Zappadoc
-- _last change by Zappadoc - 2012-12-17

-- =====================================
-- iRacing Stuff script
-- define car setup function and all pit limiter and shiftlights methods for each car you drive


function iRacing_CarSetup(cGear)
	-- get car name
	local cNm = ""
	cNm = GetContextInfo("carname")
	local mxG = 4
	local ospf = 140
	
	if cNm == "cadillacctsvr" then
		mxG = 6
		ospf = 148
		
	elseif cNm == "mclarenmp4" then
		mxG = 6
		ospf = 150

	elseif cNm == "formulamazda" then
		mxG = 6
		ospf = 60
		
	elseif cNm == "williamsfw31" then
		mxG = 7
		ospf = 90
		
	elseif cNm == "mx5 cup" or cNm == "mx5 roadster" then
		mxG = 6
		ospf = 140
		
	elseif cNm == "hpdarx01c" then
		mxG = 6
		if cGear <= 2 then 
			ospf = 10
			gOSPLimit = 9900
			gRedZone = 9920
		elseif cGear ==3 then
			ospf = 100
			gOSPLimit = 9530
			gRedZone = 9545
		elseif cGear == 4 then 
			ospf = 90
			gOSPLimit = 9500
			gRedZone = 9510
		else 
			ospf = 150
			gOSPLimit = 9420
			gRedZone = 9425
		end
		

	elseif cNm == "fordgt" then
		mxG = 6
		ospf = 128
		
	elseif cNm == "fr500s" then
		mxG = 6
		ospf = 150
				
	elseif cNm == "fordv8sc" then
		mxG = 6
		ospf = 100
		
	 elseif cNm == "dallara" then
		mxG = 6
		ospf = 95
		
	elseif cNm == "latemodel" then
		mxG = 5
		
	elseif cNm == "legends ford34c" then
		mxG = 5
		ospf = 150
		
	elseif cNm == "skmodified" then
		mxG = 6
		
	elseif cNm == "silvercrown" then
		mxG = 6
		
	elseif cNm == "trucks silverado" then
		mxG = 4
		
	elseif cNm == "stockcars impala" then
		mxG = 4
		ospf = 140
		
	elseif cNm == "lotus79" then
		mxG = 5
		ospf = 100
		
	elseif cNm == "stockcars2 chevy" then
		mxG = 4
		ospf = 130
		
	elseif cNm == "stockcars2 chevy cot" then
		mxG = 4
		ospf = 150
		
	elseif cNm == "c6r" then
		mxG = 6
		ospf = 145
		
	elseif cNm == "solstice" then
		mxG = 5
		ospf = 150
		
	elseif cNm == "jettatdi" then
		mxG = 5
		
	elseif cNm == "radical sr8" then
		mxG = 6
		ospf = 115
				
	elseif cNm == "rt2000" then
		mxG = 5
		ospf = 140
		
	elseif cNm == "specracer" then
		mxG = 5
		ospf = 140
		
	elseif cNm == "rileydp" then
		mxG = 5
		ospf = 85
		
	elseif cNm == "streetstock" then
		mxG = 4
		ospf = 150
		
	elseif cNm == "sprint" then
		mxG = 6
		
	else
		-- default 
		mxG = 4
		ospf = 150
	end
	-- set max gear and OSP factor for this car
	SetMaxGear(mxG)
	SetOSPFactor(ospf)
end

function FixRPMSpeedlimiter()
	local led = ""
	-- init table
	initLedTable(mRPMLedTable, 0)
	SetRPMLed("mRPMLedTable")
	for i = 0,12 do 
		led = led.format("RPM%d",i)
		mRPMLedTable[led] = 1
	end
	SetRPMLed("mRPMLedTable")
		
end

function iRacing_spdLmtMethodEvent(idx)
	local led = ""
	
	-- get car name
	local cNm = GetContextInfo("carname")
	
	-- speedlimiter stuff
	if cNm == "formulamazda" then
		mSpdLimitMethod = 2

	elseif cNm == "mclarenmp4" then
		mSpdLimitMethod = 2
		
	elseif cNm == "williamsfw31" then
		-- speedlimiter led fixed + digits blinking, method 6
		mSpdLimitMethod = 6
		
	elseif cNm == "fordv8sc" then
		mSpdLimitMethod = 2
		
	elseif cNm == "dallara" then
		mSpdLimitMethod = 2
	
	elseif cNm == "fordgt" then
		mSpdLimitMethod = 2
		
 	elseif cNm == "hpdarx01c" then
		FixRPMSpeedlimiter()
		return 1
		
	elseif cNm == "rileydp" then
		mSpdLimitMethod = 2
	
	elseif cNm == "c6r" then	
		FixRPMSpeedlimiter()
		return 1

	elseif cNm == "radical sr8" then
		mSpdLimitMethod = 0
	
	elseif cNm == "jettatdi" then
		mSpdLimitMethod = 2
	
	elseif cNm == "cadillacctsvr" then
		FixRPMSpeedlimiter()
		return 1
		
	-- cars with  without dashboardleds
	-- 	elseif cNm == "mx5 cup" or cNm == "mx5 roadster" then
	-- elseif cNm == "fr500s" then
	-- elseif cNm == "latemodel" then
	-- elseif cNm == "legends ford34c" then
	-- elseif cNm == "legends ford34c rookie" then
	-- elseif cNm == "skmodified" then
	-- elseif cNm == "silvercrown" then
	-- elseif cNm == "trucks silverado" then
	-- elseif cNm == "stockcars impala" then
	-- elseif cNm == "lotus79" then
	-- elseif cNm == "stockcars2 chevy" then
	-- elseif cNm == "solstice" then
	-- elseif cNm == "solstice rookie" then
	-- elseif cNm == "rt2000" then
	-- elseif cNm == "specracer" then
	-- elseif cNm == "streetstock" then
	-- elseif cNm == "sprint" then
	
	else
		-- default 
		mSpdLimitMethod = 0
		
	end
	return 2
end

function iRacing_shiftLightsMethodEvent(idx)
	-- rpm table name
	local tName = "mRPMLedTable"
	-- get rpm
	local rpm = 0
	rpm = GetCarInfo("rpm")
	if rpm == nil then rpm = 0 end
	
	-- check redzone value
	if gRedZone == nil or gRedZone == 0 then gRedZone = GetCarInfo("redzone") end

	-- get car name
	local cNm = GetContextInfo("carname")
	
	local isPit = GetCarInfo("inpits")
	local carspd =  GetCarInfo("rawspeed")
	
	-- init leds (see global.lua)
	initLedTable(mRPMLedTable, 0)
	
	-- Pits Stuff
	if isPit == 1 and carspd == 0 then
		--  pit stop
		
	elseif isPit >= 1 and carspd > 21 then
		-- car Approaching pits (or in pit lane) and exceed 45 mph
		-- set the red zone to the current engine rpm (This sets the shiftlights to the max and warns the driver)
		local spdLmt = GetCarInfo("speedlimiter")
		if spdLmt == 0 then
			-- if speedlimiter is OFF
			gRedZone = rpm
		end
	end
	
	-- shiftlights stuff
	if cNm == "formulamazda" then
		-- start Mazda shiftlights
		SideToCenterSLI(rpm, gRedZone, 94.5, 95, 96, 97 ,98 ,99 ,99.5)
	
	elseif cNm == "mclarenmp4" then
		local gear = GetCarInfo("gear")
		if gear == 6 then
			ProgressiveFixedSLI(rpm, 6300, 6490, 6580, 6690, 6720 , 6870 , 7000 , 7200, 7305, 7340, 7340, 7340, 7340)		
		else
			ProgressiveFixedSLI(rpm, 6200, 6390, 6480, 6590, 6620 , 6670 , 6750 , 6800, 6895, 7040, 7040, 7040, 7040)
		end
		
	elseif cNm == "williamsfw31" then
		AlternateSLI(rpm, gRedZone, 11.0, 12.0, 12.9)
		
	elseif cNm == "mx5 cup" or cNm == "mx5 roadster" then
		SideToCenterSLI(rpm, gRedZone, 86, 90, 95, 96 ,97 ,98 ,99)
		
	elseif cNm == "fr500s" then
		SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
		
	elseif cNm == "fordv8sc" then
		SideToCenterSLI(rpm, gRedZone, 87, 90, 92, 94 ,97 ,98 ,99)
		
	 elseif cNm == "dallara" then
		SideToCenterSLI(rpm, gRedZone, 78, 82, 90, 94 ,97 ,98 ,99)
-- 		
	elseif cNm == "fordgt" then
		SideToCenterSLI(rpm, gRedZone, 93, 94, 95, 96 ,97 ,98 ,99)
		
 	elseif cNm == "hpdarx01c" then
		ProgressiveFixedSLI(rpm, 7800, 7900, 8100, 8300, 8500 , 8700 , 8800 , 8900, 9100, 9300, 9500, 9700, 9940)
	
	elseif cNm == "rileydp" then
		ProgressiveFixedSLI(rpm, 10000, 6700, 6800, 6900, 7000 , 10000 , 10000 , 10000, 10000, 10000, 10000, 10000, 10000)
	
	elseif cNm == "c6r" then	
		ProgressiveFixedSLI(rpm, 4700, 4800, 4900, 5000, 5200 , 5300 , 5400 , 5600, 5700, 5800, 5900, 6000, 6100)

	elseif cNm == "radical sr8" then
		ProgressiveFixedSLI(rpm, 4350, 4800, 5100, 5700, 6400 , 6900 , 7700 , 8100, 8700, 9850, 10100, 10250, 10500)
	
	elseif cNm == "jettatdi" then
		SideToCenterSLI(rpm, gRedZone, 80, 84, 86, 88 ,90 ,98 ,99)
	
	elseif cNm == "cadillacctsvr" then
		--ProgressiveFixedSLI(rpm, 6500, 6580, 6600, 6700, 6800 , 6900 , 7000 , 7100, 7200, 7300, 7400, 7500, 7600)
		ProgressiveSLI(rpm, gRedZone, 11.9, 11.95, 11.98, 12, 12.1, 12.15, 12.2, 12.25, 12.3, 12.35, 12.5, 12.8, 12.98 )

	-- progressive default method for all cars with dashboard without leds 
	-- elseif cNm == "latemodel" then
	-- elseif cNm == "legends ford34c" then
	-- elseif cNm == "legends ford34c rookie" then
	-- elseif cNm == "skmodified" then
	-- elseif cNm == "silvercrown" then
	-- elseif cNm == "trucks silverado" then
	-- elseif cNm == "stockcars impala" then
	-- elseif cNm == "lotus79" then
	-- elseif cNm == "stockcars2 chevy" then
	-- elseif cNm == "solstice" then
	-- elseif cNm == "solstice rookie" then
	-- elseif cNm == "rt2000" then
	-- elseif cNm == "specracer" then
	-- elseif cNm == "streetstock" then
	-- elseif cNm == "sprint" then
	
	else
		-- default 
		ProgressiveSLI(rpm, gRedZone, 7.5, 8, 8.5, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.5, 12.8, 12.98 )
	end
		
	-- set leds
	SetRPMLed(tName)	
end

function iRacing_ospMethodEvent(idx)
	-- get car name
	local cNm = GetContextInfo("carname")
	-- OSP Method stuff
	if cNm == "mclarenmp4" or cNm == "williamsfw31" then
		if mOSPMethod ~= nil then  mOSPMethod = 3 end
	end
	return 2
end