Advertisement
wirawafiy1

HandleCommand

Jun 4th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. clearscreen.
  2.  
  3. function launch {
  4. lock throttle to 1.
  5. wait until altitude > 1000.
  6. stage.
  7. wait until apoapsis > 70000.
  8. lock throttle to 0.
  9. wait until periapsis > 70000.
  10. lock steering to prograde.
  11. lock throttle to 1.
  12. }
  13.  
  14. function launchSequence {
  15. print "Launch sequence initiated."
  16. wait until altitude > 500.
  17. stage.
  18. print "Engines ignited. Liftoff!"
  19. wait until altitude > 10000.
  20. print "Gravity turn started."
  21. lock steering to heading(90, 90).
  22. launch.
  23. print "Circular orbit achieved."
  24. }
  25.  
  26. set runLaunch to false.
  27.  
  28. function handleCommand {
  29. parameter command.
  30. if command = "launch" {
  31. if not runLaunch {
  32. runLaunch = true.
  33. print "Received launch command. Starting launch sequence."
  34. launchSequence.
  35. runLaunch = false.
  36. print "Launch process completed."
  37. } else {
  38. print "An error occurred. Launch process is already running."
  39. }
  40. } else {
  41. print "Unknown command. Please send a valid command."
  42. }
  43. }
  44.  
  45. until false {
  46. wait 0.01.
  47. if ship:control:pilotinput:hascommand {
  48. handleCommand(ship:control:pilotinput:getcommand).
  49. }
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement