Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Simple suicide burn !runscript https://pastebin.com/QQ9HaJf4
- HUDTEXT("Running script: Simple landing script",20,2,22,white,false).
- HUDTEXT("White values in GUI are adjustable",18,2,18,yellow,false).
- //Below values are tweakable and most are also shown in the GUI:
- if not(defined heightMargin) set heightMargin to 15. //extra margin in meters, will come to a stop this high above the ground before lowering slowly the rest of the way.
- if not(defined timeMargin) set timeMargin to 0.1. //in seconds, extra margin where verticalspeed * timeMargin is subtracted from the distance used in the suiocide burn calculations
- if not(defined accModifier) set accModifier to 0.9. //multiplier on how much acceleration the script thinks it has available
- if not(defined altCutoff) set altCutoff to 999999. //will not burn when alt:radar is higher than this number, no matter what. Could be useful in high atmo bodies where engines start burning way too early.
- if not(defined steeringExtraHorizontalMult) set steeringExtraHorizontalMult to 0. //set this to something > 0 to increase burning horizontally
- if not(defined minSpeed) set minSpeed to 1. // m/s, increase this if you want the final descent to be faster than 1m/s
- //STEERING - for larger crafts that have trouble turning quick enough at the end of a landing try increasing the last number below.
- lock steering to lookdirup(-velocity:surface + vxcl(up:vector, -velocity:surface) * steeringExtraHorizontalMult + up:vector * 10,facing:topvector).
- if ship:name:contains("CliffJumper") toggle ag2.
- set bnds to ship:bounds.
- set th to 0. lock throttle to th.
- when true then {
- set altR to max(0,bnds:bottomaltradar).
- if groundspeed > 10 set altR to max(0,min(altR, vdot(up:vector, bnds:furthestcorner(-up:vector)) + altitude - max(body:geopositionof(velocity:surface * 4):terrainheight,body:geopositionof(velocity:surface * 8):terrainheight))).
- set grav to body:mu/(body:radius^2).
- set acc to max(1,(max(0.05,vdot(up:vector,facing:vector)) * ship:availablethrust * accModifier) / mass - grav).
- set throttleNeutral to grav/(vdot(up:vector, facing:vector) *ship:availablethrust/mass).
- set targetSpeed to sqrt(2 * acc * max(altR - heightMargin + verticalspeed * timeMargin,0.0001)).
- set th to throttleNeutral + 4*((-verticalspeed) - max(targetSpeed, max(minSpeed,min(bnds:bottomaltradar / 1 ,10)))) / ((ship:availablethrust/mass) / grav).
- if alt:radar > altCutoff set th to 0.
- return not(ship:status = "landed" or ship:status = "splashed").
- }
- when ship:status = "landed" or ship:status = "splashed" then lock throttle to 0.
- wait 0.
- set menu to gui(200, 30). Set menu:x to -10. set menu:y to 400. menu:show.
- menu:addlabel("<b><color=yellow>Simple Landing Script</color></b>").
- set m1 to menu:addlabel("heightMargin:").
- set m2 to menu:addlabel("timeMargin:").
- set m3 to menu:addlabel("accModifier :").
- set m8 to menu:addlabel("altCutoff :").
- set m9 to menu:addlabel("altCutoff :").
- set m4 to menu:addlabel("Est. Height:").
- set m5 to menu:addlabel("Verticalspeed:").
- set m6 to menu:addlabel("TargetSpeed:").
- set m7 to menu:addlabel("TWR:").
- menu:addlabel("<i>'menu:hide'</i> to close").
- for txt in menu:widgets { set txt:style:fontsize to 14. set txt:style:padding:v to 1. }
- on time:second {
- set m1:text to "heightMargin: <color=white>" + heightMargin + "m</color>".
- set m2:text to "timeMargin: <color=white>" + timeMargin + "s</color>".
- set m3:text to "accModifier: <color=white>" + accModifier + "</color>".
- set m8:text to "altCutoff: <color=white>" + altCutoff + "m</color> (radar)".
- set m9:text to "steeringExtraHorizontalMult: <color=white>" + steeringExtraHorizontalMult + "x</color>".
- set m7:text to "TWR: " + round((ship:availablethrust/mass) / grav,2).
- return menu:visible.
- }
- when true then {
- set m4:text to "Est. Height: " + round(altR) + "m".
- set m5:text to "Verticalspeed: " + round(verticalspeed) + "m/s".
- set m6:text to "TargetSpeed:" + round(-targetSpeed) + "m/s".
- return menu:visible.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement