chazmister56

chazmister56 - Gmod Public Steering Chip

Dec 15th, 2024 (edited)
1,681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.09 KB | Source Code | 0 0
  1. @name chazmister56 - SimpleSteer 2025 Public V2
  2. @inputs A D Active Base:entity
  3. @outputs Speed TURN Smooth1 Smooth2
  4. @persist AntiWobbleAngle TURN_ANGLE TURN_RATE SpeedEffect Counter SLAVE:entity CASTER
  5. @model models/sprops/rectangles_thin/size_2/rect_12x12x1_5.mdl
  6.  
  7.     #MADE BY chazmister56#
  8.     #youtube: https://www.youtube.com/@chazmister56
  9.  
  10.     ########################################
  11.     ######## |||| INSTRUCTIONS |||| ########
  12.     ########################################
  13.    
  14.     #Always wire the chip up entirely BEFORE you ballsocket
  15.     #your wheels to it. If you do not do this, your
  16.     #wheels will likely snap 90 degrees to the wrong
  17.     #direction after you unfreeze your car.
  18.  
  19.     #Wire Active to Active on your pod
  20.     #Base wires to the baseplate of your car
  21.     #A and D go to their respective keys on the pod
  22.    
  23. interval(Active ? 44 : 250)
  24.  
  25. if(first()|dupefinished()){
  26.    
  27.     TURN_ANGLE = 45 #This sets the maximum angle your wheels can turn.
  28.    
  29.     CASTER = -0.2 #This pivots the angle the wheels steer at(forward/backward).
  30.                  #It can be 0, as it is not entirely necessary to run on cars in Gmod.
  31.                  #Make negative if the caster is leaning opposite of what you want.
  32.    
  33.     TURN_RATE = 2 #This sets the steering speed. Higher number for quicker steering.
  34.    
  35.     AntiWobbleAngle = 1.2 #This sets a "deadzone" in the steering that helps eliminate steering wobble when not steering.
  36.                           #I recommend you keep this setting between 0-1.5. Too big of a number can cause unwanted input behavior.
  37.                           #Soft/sloppy suspension may be the cause of your wobbles if you need a bigger number.
  38.    
  39.     Counter = 20 #This sets the countersteer power. A lower number will make it stronger, and the opposite makes it weaker.
  40.    
  41.     SpeedEffect = 700 #This slows steering based on speed. A lower number will make it stronger.(Same rules as Counter setting)
  42.                    
  43.    
  44.     ##DO NOT TOUCH BELOW THIS LINE##
  45.    
  46.     SLAVE=entity() #Do not touch
  47.     print("Thanks for using Simple Gyro Steering by chazmister56.")
  48.     print("Channel link: https://www.youtube.com/@chazmister56")
  49. }
  50.     #########################################
  51.     # |||| DO NOT TOUCH ANYTHING BELOW |||| #
  52.     #########################################
  53.    
  54.     function number customLerp(A:number, B:number, X:number){
  55.         return A * ( 1 - X ) + B * X
  56.     }
  57.  
  58.     Smooth1 = customLerp(Smooth1, A, TURN_RATE * tickInterval())
  59.     Smooth2 = customLerp(Smooth2, D, TURN_RATE * tickInterval())
  60.     Smooth1 *= A
  61.     Smooth2 *= D
  62.    
  63.     Speed = Base:vel():length()/17.6 #Speed based in MPH
  64.  
  65.     TURN += clamp((Smooth2-Smooth1)*TURN_ANGLE-TURN/15,-TURN_RATE,TURN_RATE)
  66.     TURN += Base:angVel():yaw()/Counter
  67.     TURN = clamp(TURN,-TURN_ANGLE,TURN_ANGLE)
  68.     TURN *= abs(TURN) < AntiWobbleAngle & (!A & !D) ? 0.5 : 1
  69.     TURN = TURN*(1-Speed/SpeedEffect)
  70.  
  71.  
  72. if(!SLAVE:isPlayerHolding()){
  73.     SLAVE:setAng(Base:toWorld(ang(0,-TURN,-TURN*CASTER)))
  74.     SLAVE:propFreeze(1)
  75. }
  76.  
  77.  
  78. if(~Base & Base:isValid()) {
  79.     reset()
  80. }
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment