Advertisement
sumguytwitches

hathi Tylo vspeed 0 takeoff

Feb 18th, 2023 (edited)
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. lock liquidmatched to min(ship:oxidizer * 9 / 11, ship:liquidfuel).
  2. lock NukeLiquid to max(0, ship:liquidfuel-liquidmatched).
  3. lock nukedv to Round(800 * 9.81 * ln(ship:mass / (ship:mass - (NukeLiquid * 0.005))), 5).
  4.  
  5. lock oxidizermatched to min(ship:oxidizer, ship:liquidfuel * 11 / 9).
  6. lock vectordv to Round(315 * 9.81 * ln((ship:mass - (NukeLiquid * 0.005)) / ((ship:mass - (NukeLiquid * 0.005)) - (liquidmatched * 0.005) - (oxidizermatched * 0.005))), 5).
  7.  
  8.  
  9. function SetEngines {
  10. parameter targetMode to "Activate Engine".
  11. parameter engines to ship:partsdubbedpattern("vector").
  12. for engine in engines {
  13. if engine:hasmodule("ModuleEnginesFx") set m to engine:getmodule("ModuleEnginesFx").
  14. if engine:hasmodule("ModuleEngines") set m to engine:getmodule("ModuleEngines").
  15. if m:hasaction(targetMode) m:doaction(targetMode, true).
  16. }
  17. }
  18.  
  19. function ThrustLimit {
  20. parameter targetEngines.
  21. parameter targetThrust.
  22. for eng in targetEngines set eng:thrustlimit to targetThrust.
  23. }
  24.  
  25. function SetAngle {
  26. parameter targetangle.
  27. for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
  28. }
  29.  
  30. function info {
  31. parameter message.
  32.  
  33. set logmessage to round(missionTime,1) + ": " + message.
  34. print logmessage.
  35. }
  36.  
  37.  
  38.  
  39. for i in range(terminal:height-3) Print "":padright(terminal:width).
  40.  
  41. set steeringmanager:rollcontrolanglerange to 180.
  42. toggle ag9.
  43. rcs on.
  44. set targetOrbitAltitude to 20e3.
  45.  
  46. set vectors to ship:partsdubbedpattern("vector").
  47. set nukes to ship:partsdubbedpattern("nuc").
  48. set servos to ship:modulesnamed("ModuleRoboticRotationServo").
  49. lock p to 0.
  50. brakes off.
  51. lock steering to heading(90,p).
  52.  
  53. SetEngines("Activate Engine", vectors).
  54. SetEngines("Activate Engine", nukes).
  55. lock throttle to choose apoapsis-periapsis > 500 if eta:apoapsis < 30 or apoapsis < targetOrbitAltitude else choose 30-eta:apoapsis if periapsis < 19e3 else 0.
  56. when nukedv < 1 then setEngines("Shutdown Engine", nukes).
  57. lock angletarget to 90-vang(up:vector, ship:facing:vector).
  58. when alt:radar > 26 then {
  59. gear off.
  60. info("engage dynamic servo").
  61. lock angletarget to max(0, min(90,(apoapsis/targetOrbitAltitude)*90 + 90-vang(up:vector, ship:facing:vector))).
  62. rcs off.
  63. }
  64.  
  65.  
  66.  
  67.  
  68. set anglecopy to angletarget.
  69.  
  70. when true then{
  71. set anglecopy to angletarget.
  72. SetAngle(anglecopy).
  73. print "servo angle: " + anglecopy at (0,1).
  74. print " p: " + p at (0,2).
  75. print " apoapsis: " + apoapsis at (0,3).
  76. print " periapsis: " + periapsis at (0,4).
  77. return apoapsis-periapsis > 500 .
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement