|
1 | | -currentSpeed = 0 |
2 | | -maxSpeed = 5 |
3 | | -minSpeed = 0.1 |
4 | | - |
5 | | -incSpeed = 1 |
6 | | - |
7 | | -function onUpPressed() |
8 | | - System.LogAlways("OnUP aa") |
9 | | - |
10 | | - if (currentSpeed < maxSpeed) then |
11 | | - currentSpeed = currentSpeed + incSpeed |
12 | | - end |
13 | | - |
14 | | - System.LogAlways("Current speed: " .. tostring(currentSpeed)) |
15 | | -end |
16 | | - |
17 | | -System.AddCCommand('onUpPressed', 'onUpPressed()', "onUpPressed!") |
18 | | -System.ExecuteCommand("bind 'w' onUpPressed ") |
19 | | - |
20 | | -function onDownPressed() |
21 | | - System.LogAlways("OnDown") |
22 | | - |
23 | | - if (currentSpeed > 0) then |
24 | | - currentSpeed = currentSpeed - incSpeed |
25 | | - end |
26 | | - |
27 | | - System.LogAlways("Current speed: " .. tostring(currentSpeed)) |
28 | | -end |
29 | | - |
30 | | -System.AddCCommand('onDownPressed', 'onDownPressed()', "onDownPressed!") |
31 | | -System.ExecuteCommand("bind 's' onDownPressed ") |
32 | | - |
33 | | -mechaSlideActive = false |
34 | | - |
35 | | -function onSlideUpdate() |
36 | | - |
37 | | - if not mechaSlideActive then |
38 | | - return |
39 | | - end |
40 | | - |
41 | | - local from = player:GetPos(); |
42 | | - from.z = from.z + 1.615; |
43 | | - |
44 | | - local hitData = {}; |
45 | | - local hits = Physics.RayWorldIntersection( |
46 | | - from, |
47 | | - vecScale(System.GetViewCameraDir(), 250), |
48 | | - 10, |
49 | | - ent_all, |
50 | | - player.id, |
51 | | - nil, |
52 | | - hitData |
53 | | - ); |
54 | | - |
55 | | - if hits > 0 then |
56 | | - -- dump(hitData[1]) |
57 | | - |
58 | | - firstHit = hitData[1] |
59 | | - |
60 | | - p = player:GetPos() |
61 | | - |
62 | | - c = System.GetViewCameraDir() |
63 | | - |
64 | | - local from = player:GetPos(); |
65 | | - from.z = from.z + 1.615; |
66 | | - |
67 | | - local hitDownToBottom = {}; |
68 | | - local hitsDownToBottom = Physics.RayWorldIntersection(from, { x = 0, y = 0, z = -5 }, 10, ent_all, player.id, nil, hitDownToBottom); |
69 | | - |
70 | | - local frontData = {}; |
71 | | - camView = vecScale(System.GetViewCameraDir(), 10) |
72 | | - newCamView = { |
73 | | - camView.x, |
74 | | - camView.y, |
75 | | - camView.z |
76 | | - } |
77 | | - local frontHits = Physics.RayWorldIntersection(from, newCamView, 10, ent_all, player.id, nil, frontData); |
78 | | - |
79 | | - if (frontHits <= 0) then |
80 | | - return |
81 | | - end |
82 | | - |
83 | | - up = { |
84 | | - p.x + c.x * (0.1 * currentSpeed), |
85 | | - p.y + c.y * (0.1 * currentSpeed), |
86 | | - -- p.z + c.z * 0 |
87 | | - hitDownToBottom[1].pos.z + 0.1 |
88 | | - } |
89 | | - |
90 | | - player:SetPos(up) |
91 | | - |
92 | | - end |
93 | | - |
94 | | -end |
| 1 | +-- currentSpeed = 0 |
| 2 | +-- maxSpeed = 5 |
| 3 | +-- minSpeed = 0.1 |
| 4 | +-- |
| 5 | +-- incSpeed = 1 |
| 6 | +-- |
| 7 | +-- function onUpPressed() |
| 8 | +-- System.LogAlways("OnUP aa") |
| 9 | +-- |
| 10 | +-- if (currentSpeed < maxSpeed) then |
| 11 | +-- currentSpeed = currentSpeed + incSpeed |
| 12 | +-- end |
| 13 | +-- |
| 14 | +-- System.LogAlways("Current speed: " .. tostring(currentSpeed)) |
| 15 | +-- end |
| 16 | +-- |
| 17 | +-- System.AddCCommand('onUpPressed', 'onUpPressed()', "onUpPressed!") |
| 18 | +-- System.ExecuteCommand("bind 'w' onUpPressed ") |
| 19 | + |
| 20 | +-- function onDownPressed() |
| 21 | +-- System.LogAlways("OnDown") |
| 22 | +-- |
| 23 | +-- if (currentSpeed > 0) then |
| 24 | +-- currentSpeed = currentSpeed - incSpeed |
| 25 | +-- end |
| 26 | +-- |
| 27 | +-- System.LogAlways("Current speed: " .. tostring(currentSpeed)) |
| 28 | +-- end |
| 29 | +-- |
| 30 | +-- System.AddCCommand('onDownPressed', 'onDownPressed()', "onDownPressed!") |
| 31 | +-- System.ExecuteCommand("bind 's' onDownPressed ") |
| 32 | +-- |
| 33 | +-- mechaSlideActive = false |
| 34 | +-- |
| 35 | +-- function onSlideUpdate() |
| 36 | +-- |
| 37 | +-- if not mechaSlideActive then |
| 38 | +-- return |
| 39 | +-- end |
| 40 | +-- |
| 41 | +-- local from = player:GetPos(); |
| 42 | +-- from.z = from.z + 1.615; |
| 43 | +-- |
| 44 | +-- local hitData = {}; |
| 45 | +-- local hits = Physics.RayWorldIntersection( |
| 46 | +-- from, |
| 47 | +-- vecScale(System.GetViewCameraDir(), 250), |
| 48 | +-- 10, |
| 49 | +-- ent_all, |
| 50 | +-- player.id, |
| 51 | +-- nil, |
| 52 | +-- hitData |
| 53 | +-- ); |
| 54 | +-- |
| 55 | +-- if hits > 0 then |
| 56 | +-- -- dump(hitData[1]) |
| 57 | +-- |
| 58 | +-- firstHit = hitData[1] |
| 59 | +-- |
| 60 | +-- p = player:GetPos() |
| 61 | +-- |
| 62 | +-- c = System.GetViewCameraDir() |
| 63 | +-- |
| 64 | +-- local from = player:GetPos(); |
| 65 | +-- from.z = from.z + 1.615; |
| 66 | +-- |
| 67 | +-- local hitDownToBottom = {}; |
| 68 | +-- local hitsDownToBottom = Physics.RayWorldIntersection(from, { x = 0, y = 0, z = -5 }, 10, ent_all, player.id, nil, hitDownToBottom); |
| 69 | +-- |
| 70 | +-- local frontData = {}; |
| 71 | +-- camView = vecScale(System.GetViewCameraDir(), 10) |
| 72 | +-- newCamView = { |
| 73 | +-- camView.x, |
| 74 | +-- camView.y, |
| 75 | +-- camView.z |
| 76 | +-- } |
| 77 | +-- local frontHits = Physics.RayWorldIntersection(from, newCamView, 10, ent_all, player.id, nil, frontData); |
| 78 | +-- |
| 79 | +-- if (frontHits <= 0) then |
| 80 | +-- return |
| 81 | +-- end |
| 82 | +-- |
| 83 | +-- up = { |
| 84 | +-- p.x + c.x * (0.1 * currentSpeed), |
| 85 | +-- p.y + c.y * (0.1 * currentSpeed), |
| 86 | +-- -- p.z + c.z * 0 |
| 87 | +-- hitDownToBottom[1].pos.z + 0.1 |
| 88 | +-- } |
| 89 | +-- |
| 90 | +-- player:SetPos(up) |
| 91 | +-- |
| 92 | +-- end |
| 93 | +-- |
| 94 | +-- end |
0 commit comments