Advertisement
sumguytwitches

supersonic control

Jul 18th, 2022 (edited)
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. core:doevent("open terminal").
  2. wait 4.
  3. brakes on.
  4. wait 1.
  5. lock torque to 0.
  6. when vang(sun:position, up:vector) < 10 then {
  7. set warp to 0.
  8. brakes off.
  9. steeringmanager:resetpids().
  10. wait 1.
  11. lock torque to max((100-ship:electriccharge),throttle * 100).
  12. }
  13. set warpmode to "rails". set warp to 5.
  14.  
  15. set steeringmanager:pitchtorquefactor to 0.2.
  16. set steeringmanager:yawtorquefactor to 0.5.
  17. set steeringmanager:rollcontrolanglerange to 180.
  18.  
  19. set blades to ship:partsdubbedpattern("blade").
  20.  
  21.  
  22. set rotors to ship:modulesnamed("ModuleRoboticServoRotor").
  23.  
  24. set proprad to 5.8.
  25. set aoatopressure to 9.//4.387475597 / body:atm:altitudepressure(4997).
  26.  
  27. set taralt to 5.
  28. set taraoa to 3.333.
  29.  
  30.  
  31. lock relativeAirspeed to airspeed.
  32. lock deploy to taraoa + arctan(relativeAirspeed/(2 * constant:pi * proprad * 459/60)).
  33.  
  34.  
  35.  
  36.  
  37. set bladeMods to list().
  38. For b in blades {
  39. set bmod to b:getmodule("ModuleControlSurface").
  40. bmod:setfield("deploy", true).
  41. bladeMods:add(bmod).
  42. }
  43.  
  44. lock mach to sqrt(2 / 1.4 * ship:q / body:atm:altitudepressure(altitude)).
  45.  
  46.  
  47. set x to 90.
  48. lock p to min(15,max(-3, -verticalSpeed*1.7 + (taralt - alt:radar)/2.5)).
  49. lock steering to heading(x,p).
  50. lock throttle to 1.
  51.  
  52. when verticalSpeed > 1 or airspeed > 200 then gear off.
  53.  
  54. when true then {
  55. set torquecopy to torque.
  56. set deploycopy to deploy.
  57.  
  58. for rt in rotors rt:setfield("torque limit(%)", torquecopy).
  59. For b in bladeMods b:setfield("deploy angle", deploycopy).
  60.  
  61. return true.
  62. }
  63.  
  64. set sgp to 0.
  65. set sggo to true.
  66. set sgf to 8.
  67. set sgpr to 4.
  68. function sgd {
  69. parameter l. parameter d.
  70. If l:length > sgpr set sgpr to l:length.
  71. print (l:padleft(sgpr) + ": " +round(d,2)):padright(terminal:width) at (0, sgp).
  72. set sgp to sgp + 1.
  73. }.
  74.  
  75.  
  76.  
  77.  
  78.  
  79. set sggo to false. wait 0. set sggo to true.
  80. On round(kuniverse:realtime * sgf) {
  81. set sgp to 0.
  82.  
  83. sgd("torque", torque).
  84. sgd("deploy", deploy).
  85. sgd("Verticalspeed", verticalspeed).
  86. sgd("target aoa",taraoa).
  87. sgd("altitude",altitude).
  88. sgd("airspeed", airspeed).
  89. sgd("aoa", vang(ship:facing:vector,ship:velocity:surface)).
  90. sgd("mach", mach).
  91. sgd("EC", ship:electriccharge).
  92.  
  93. Print "":padright(terminal:width) at (0,sgp).
  94. Set sgp to sgp + 1.
  95. Print "":padright(terminal:width) at (0,sgp).
  96. return sggo.
  97. }
  98.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement