Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. -- Tick function that will be executed every logic tick
  2. function onTick()
  3.  
  4. -----INPUTS-----------------
  5. up = input.getNumber(1)
  6. speed = input.getNumber(2)
  7. clutch = input.getNumber(3)
  8. rps = input.getNumber(4)
  9. throt = input.getNumber(5)
  10. time = input.getNumber(6)
  11. ----END OF INPUTS-------------
  12.  
  13.  
  14. ---GEAR CODE-------------------
  15.  
  16. if up == 0 then --neutral--
  17. d = 0
  18. output.setNumber(2,0)
  19. output.setNumber(1, 0)
  20. end
  21.  
  22. if up == -1 then
  23. output.setNumber(1, -0.15)
  24. end
  25.  
  26.  
  27. if up == 1 then --first--
  28. d = 1
  29. output.setNumber(1, 0.1)
  30. output.setBool(4, false)
  31. output.setBool(3, false)
  32. output.setBool(2, false)
  33. output.setBool(1, false)
  34. output.setNumber(2, 1)
  35. end
  36.  
  37.  
  38.  
  39.  
  40. if up == 1 and speed > 70 then --second--
  41. output.setBool(4, false)
  42. output.setBool(3, false)
  43. output.setBool(2, true)
  44. output.setBool(1, true)
  45. output.setNumber(1, 0.2)
  46. two = 1
  47. end
  48.  
  49.  
  50. if up == 1 and speed > 140 then --third--
  51. output.setBool(4, false)
  52. output.setBool(3, true)
  53. output.setBool(2, false)
  54. output.setBool(1, false)
  55. output.setNumber(1, 0.3)
  56. end
  57.  
  58.  
  59.  
  60. if up == -1 then --reverse--
  61. d = 1
  62. output.setBool(4, true)
  63. output.setBool(3, false)
  64. output.setBool(2, false)
  65. output.setBool(1, true)
  66. output.setNumber(1, -0.15)
  67. output.setNumber(2, 1)
  68. end
  69.  
  70. if speed < 20 then
  71. output.setNumber(2, 0.5)
  72. end
  73.  
  74. if throt <= 0 and time > 2 then
  75. output.setNumber(2,0)
  76. end
  77.  
  78. if throt <= 0 and speed < 3 then
  79. output.setNumber(2,0)
  80. end
  81.  
  82. if throt > 0 and up == 1 then
  83. output.setNumber(2,1)
  84. end
  85.  
  86. if throt > 0 and up == -1 then
  87. output.setNumber(2,1)
  88. end
  89.  
  90.  
  91.  
  92.  
  93. --end of gear code--------
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement