-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGear System 3.CEA
126 lines (103 loc) · 2.82 KB
/
Gear System 3.CEA
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
{$lua}
[ENABLE]
local mul=1+3e-3
local gearMul=1.3
local rangeShifter=0.3
local Up=0.1
local Down=0
local motion=0.1
local speedXString='X SPEED road'
local speedYString='Y SPEED road'
local speedZString='Z SPEED road'
--Instructions
--mul is the speed by which the car will accelerate if the speed of the car is in range of (TempUp,TempDown)
--gearMul is the speed by which the car will be forced such that finally the speed of the car comes under the range of (TempUp,TempDown).Setting a higher value for gearMul will result in huge jerks but lower value for this will result in late input reaction.
--rangeMultiplier is the multiplier by which the range will be multiplied to calculate the new bottom and top speed.
--Up is the initial top speed
-- Down is the initial bottom speed
--motion is the threshold for the speed of the car so that script may start to work normally.
--In this,range is adjusted by constants.
--Gear is increased by W and decreased by S
local TempUp=Up
local TempDown=Down
t=getAddressList()
x=t.getMemoryRecordByDescription(speedXString)
y=t.getMemoryRecordByDescription(speedYString)
z=t.getMemoryRecordByDescription(speedZString)
function adjustSpeed(x,y,tempUp,tempDown,speedUp)
r=((x.Value^2)+(y.Value^2)+(z.Value^2))^0.5
if r<tempDown then
if r*gearMul<=tempDown then
x.Value=x.Value*gearMul
y.Value=y.Value*gearMul
z.Value=z.Value*gearMul
else
ratio=tempDown/r
x.Value=x.Value*ratio
y.Value=y.Value*ratio
z.Value=z.Value*ratio
end
elseif r>=tempDown and r<tempUp then
if r*mul<=tempUp then
if speedUp then
x.Value=x.Value*mul
y.Value=y.Value*mul
z.Value=z.Value*mul
else
x.Value=x.Value/mul
y.Value=y.Value/mul
z.Value=z.Value/mul
end
else
ratio=tempUp/r
x.Value=x.Value*ratio
y.Value=y.Value*ratio
z.Value=z.Value*ratio
end
else
if r/gearMul>tempUp then
x.Value=x.Value/gearMul
y.Value=y.Value/gearMul
z.Value=z.Value/gearMul
else
ratio=tempUp/r
x.Value=x.Value*ratio
y.Value=y.Value*ratio
z.Value=z.Value*ratio
end
end
end
hk1=createHotkey(function()
adjustSpeed(x,y,TempUp,TempDown,1)
end,0x26)
left=createHotkey(function()
adjustSpeed(x,y,TempUp,TempDown,0)
end,0x25)
right=createHotkey(function()
adjustSpeed(x,y,TempUp,TempDown,0)
end,0x27)
hk3=createHotkey(function()
TempDown=TempUp
TempUp=TempUp+rangeShifter
adjustSpeed(x,y,TempUp,TempDown)
speak('Gear Up')
end,0x57)
hk6=createHotkey(function()
TempUp=TempDown
TempDown=TempDown-rangeShifter
adjustSpeed(x,y,TempUp,TempDown,1)
speak('Gear Down')
end,0x53)
hk7=createHotkey(function()
TempUp=Up
TempDown=Down
adjustSpeed(x,y,TempUp,TempDown,1)
speak('Reset')
end,0x20)
[DISABLE]
hk1.destroy()
hk3.destroy()
hk6.destroy()
hk7.destroy()
left.destroy()
right.destroy()