summaryrefslogtreecommitdiff
path: root/scripts/zdoc_scripts/iracing_common_scripts.lua
blob: 1da0e2de0ad50475054b624022d579303f69e07d (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
-- iRacing SLI-PRO Custom SLIMax Manager Scripts v3.2.2
-- Copyright ©2012-2013 by Zappadoc - All Rights Reserved.
-- last change by Zappadoc - 2013-10

-- ================================
-- CONSTANTS


-- ================================
-- additional lua extension module dll


-- ================================
-- additional scripts file
require "scripts/zdoc_scripts/iracing_stuff"

-- ================================
-- custom globals


-- ================================
-- custom functions

-- ================================
-- custom events

function custom_initEvent(scriptfile)
	-- type your custom script initialization here
	-- if iRacingZDocComboInitialized == nil then
		-- iRacingZDocComboInitialized = true
		-- local devStr = GetDeviceType(GetContextInfo("devicetype"))
		-- if devStr == nil then devStr = "Unknown" end
		-- local str = string.format("iRacing Combo Setup (settings + scripts)\n©2012-2013 By zappadoc, All Rights Reserved.\n\nInitialized for device: %s\n\nReminder: A COMBO SETUP automatically chooses for you the best corresponding settings in the car you are currently driving. Change to a simple setup if you want to set up the car by yourself using Basic or Advanced Options panel.", devStr )
		-- SMXMessageBox(str)
	-- end
end

-- function custom_controlsEvent(deviceType, ctrlType, ctrlPos, value, funcIndex)
	-- -- type your custom controls script here (manage buttons, switches and encoders)
	-- return 2
-- end

-- function custom_deviceReport(deviceType)
	-- -- type your script here (just before sending report to the device )
	-- return 2
-- end

function UnifyOSPMethod(idx, device)
	-- custom OSP for each iRacing car
	local result = 2
	-- get current simulation name
	local sim = GetContextInfo("simulation")
	if isAppIRacing(sim) then
		result = iRacing_ospMethodEvent(idx, device)
	end
	return result
end

function custom_ospMethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here

	return UnifyOSPMethod(idx, "SLI")
end

function custom_ospFanatecMethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here
		-- custom speedlimiter for each iRacing car
	return UnifyOSPMethod(idx, "FANATEC")
end

function custom_ospSRDlxMethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here
		-- custom speedlimiter for each iRacing car
	return UnifyOSPMethod(idx, "SRDLX")
end
function custom_ospSRF1MethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here
		-- custom speedlimiter for each iRacing car
	return UnifyOSPMethod(idx, "SRF1")
end

--==================================================

function UnifyShiftlightsMethod(idx, device)
	-- custom shiftlights for each iRacing car
	-- get current simulation name
	local sim = GetContextInfo("simulation")
	if isAppIRacing(sim) then
		iRacing_shiftLightsMethodEvent(idx, device)
		-- skip std methods
		return 1
	end
	return 2
end

function custom_shiftLightsSRDlxMethodEvent(idx)
	-- type your custom shiftlights method here
	
	return UnifyShiftlightsMethod(idx, "SRDLX")
end

function custom_shiftLightsMethodEvent(idx)
	-- type your custom shiftlights method here
	
	return UnifyShiftlightsMethod(idx, "SLI")
end

function custom_shiftLightsFanatecMethodEvent(idx)
	-- type your custom shiftlights method here
	
	return UnifyShiftlightsMethod(idx, "FANATEC")
end

function custom_shiftLightsSRF1MethodEvent(idx)
	-- type your custom shiftlights method here
	
	return UnifyShiftlightsMethod(idx, "SRF1")
end

-- function custom_shiftLightsBU0710Event(idx)
	-- -- type your custom shiftlights method for BU0710 device only here
	-- return 2
-- end

-- function custom_leftDigitsEvent(swPosition)
	-- -- type your custom script related to left SLI-PRO digits panel here
	-- return 2
-- end

-- function custom_rightDigitsEvent(swPosition)
	-- -- type your custom script related to right SLI-PRO digits panel here
	-- return 2
-- end

-- function custom_fanatecDigitsEvent(swPosition)
	-- -- type your custom script related to Fanatec digits panel here
	-- return 2
-- end

--==================================================

function UnifySpeedlimiterMethod(idx, device)
	-- type your custom speedlimiter method here
		
	-- custom speedlimiter for each iRacing car
	local result = 2
	-- get current simulation name
	local sim = GetContextInfo("simulation")
	if isAppIRacing(sim) then
		result = iRacing_spdLmtMethodEvent(idx, device)
	end
	return result
end

function custom_spdLmtMethodEvent(idx)
	-- type your custom speedlimiter method here

	return UnifySpeedlimiterMethod(idx, "SLI")
end

function custom_spdLmtFanatecMethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here

	return UnifySpeedlimiterMethod(idx, "FANATEC")
end

function custom_spdLmtSRDlxMethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here

	return UnifySpeedlimiterMethod(idx, "SRDLX")
end

function custom_spdLmtSRF1MethodEvent(idx)
	-- type your custom Optimal Shift Points (OSP) method here

	return UnifySpeedlimiterMethod(idx, "SRF1")
end
--==================================================

function UnifyGearEvent(gear)
	local sim = GetContextInfo("simulation")
	if isAppIRacing(sim) then	
		iRacing_InitGearEvent(gear)
	end
end

function custom_gearFanatecEvent(gear)
	-- type your custom gear event script here
	
	UnifyGearEvent(gear)
	return 2
end

function custom_gearEvent(gear)
	-- type your custom gear event script here
	
	UnifyGearEvent(gear)
	return 2
end

--==================================================

function custom_enterSessionEvent(deviceType)
	-- type your custom script on session start, here

	-- custom script to get the max gear of each iRacing car
	-- get current simulation name
	local sim = GetContextInfo("simulation")
	if isAppIRacing(sim ) then
		iRacing_CarSetup(0)
		iRacing_DebugCarInfo(deviceType)
	end
	return 2
end

-- function custom_exitSessionEvent(deviceType)
	-- -- type your custom script on session ending, here
	-- return 2
-- end