Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. core:doevent("open terminal").
  2. wait 3.
  3. local shipheight to alt:radar + vdot(core:part:position, up:vector).
  4.  
  5. local lptgt to latlng(latitude, longitude).
  6.  
  7. local tth to lptgt:terrainheight.
  8. lock steering to lookdirup(up:vector, facing:upvector).
  9. lock throttle to 1.
  10. stage.
  11.  
  12. lock steering to lookdirup(up:vector + north:vector * 0.01, facing:upvector).
  13.  
  14. wait until apoapsis > 3000 + tth.
  15. lock throttle to 0.
  16. wait until verticalspeed < -40.
  17.  
  18. local hnow to alt:radar + vdot(core:part:position, up:vector) - shipheight.
  19. set drawVel to vecdraw(v(0,0,0), v(0,0,0), blue, "Landing target", 1.0, true).
  20. until hnow < 0.3 {
  21. set hnow to altitude - tth + vdot(core:part:position, up:vector) - shipheight.
  22. local vs to velocity:surface.
  23. local vv to verticalspeed.
  24. local tpos to lptgt:position.
  25. set drawVel:vecupdater to { return tpos. }.
  26. local bp to body:position.
  27. local avmag to vv * vv * 0.5 / hnow.
  28. local avthrmag to avmag + body:mu / bp:sqrmagnitude.
  29. local tti to abs(vv) / avmag.
  30. local ah to vxcl(bp, (12 * tpos / tti - 6 * vs)) / tti.
  31. if ah:mag / avthrmag > 0.1 set ah to 0.1 * ah:normalized * avthrmag.
  32. local steervec to up:vector * avthrmag + ah.
  33. lock steering to lookdirup(steervec, facing:upvector).
  34. local hovslthrot to mass * sqrt(ah:sqrmagnitude + avthrmag^2) / availablethrust.
  35. if throttle > 0 or hovslthrot > 0.95 {
  36. set throttle to hovslthrot.
  37. }
  38. wait 0.
  39. }
  40.  
  41. lock throttle to 0.
  42. wait until ship:status = "landed".
  43. set ship:control:pilotmainthrottle to 0.
  44. unlock all.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement