Advertisement
HolyDogelord

E2 MonoWheel Script

Aug 25th, 2019
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. @name Monowheel Controller
  2. @inputs W A S D Space Shift Alt R Active
  3. @inputs BASE:entity BRAKEPLATE:entity WHEEL:entity DRIVERSEAT:entity PASSENGERSEAT:entity
  4. @outputs Lock Eject HydraulicLength HydraulicStrength HydraulicDamping
  5. @persist Direction Parked RollSpeed ROLL_FORCE SELF:entity OWNER:entity
  6. @trigger
  7. function park(Val:number){
  8. if (Val){
  9. Parked = 1
  10. HydraulicLength = 40
  11. HydraulicStrength = 100000
  12. HydraulicDamping = 2000
  13. BRAKEPLATE:setMass(500)
  14. #BRAKEPLATE:propNotSolid(0)#
  15. }
  16. else{
  17. Parked = 0
  18. HydraulicLength = 0
  19. HydraulicStrength = 1000
  20. HydraulicDamping = 100
  21. BRAKEPLATE:setMass(0.1)
  22. #BRAKEPLATE:propNotSolid(0)#
  23. }
  24. }
  25. if (first()|dupefinished()){
  26. #define variables here
  27. SELF = entity()
  28. OWNER = owner()
  29. Direction = 0
  30. WheelAngle = ang(0, 0, 0)
  31. ROLL_FORCE = 1000
  32. RollSpeed = 1
  33. WHEEL:propSetFriction(1000)
  34. park(1)
  35. runOnTick(1)
  36. }
  37. elseif (tickClk()){
  38. if (!Parked){
  39. Angle = ang(0,Direction,0)
  40. AppForce = (BASE:toLocal(Angle)*ang(250,250,250) - BASE:angVel()*25)*shiftL(ang(BASE:inertia()))
  41. BASE:applyAngForce(AppForce)
  42. if (W) {
  43. WHEEL:applyTorque(-vec(ROLL_FORCE * RollSpeed * WHEEL:mass(), 0, 0))
  44. }
  45. if (S) {
  46. WHEEL:applyTorque(vec(ROLL_FORCE * RollSpeed * WHEEL:mass(), 0, 0))
  47. }
  48. if (A) {
  49. Direction += 1.5
  50. }
  51. if (D) {
  52. Direction -= 1.5
  53. }
  54. }
  55. }
  56. elseif (~Alt & Alt){
  57. if (Lock) { Lock = 0
  58. DRIVERSEAT:hintDriver("Unlocked passenger seat", 2)
  59. PASSENGERSEAT:setColor(255, 255, 255) }
  60. else { Lock = 1
  61. DRIVERSEAT:hintDriver("Locked passenger seat", 2)
  62. PASSENGERSEAT:setColor(255, 0, 0)}
  63. }
  64. elseif (~R & R){
  65. Eject = R
  66. DRIVERSEAT:hintDriver("Ejected passenger", 2)
  67. }
  68. elseif (~Active){
  69. if (!Active){
  70. park(1)
  71. }
  72. else{
  73. park(0)
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement