Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //!runscript mP17Lg3L
- set sggo to true.
- set sgp to 0.
- set sgf to 8.
- set sgpr to 4.
- set sgfirst to 0.
- function sgd {
- parameter l. parameter d.
- If l:length > sgpr set sgpr to l:length.
- print (l:padleft(sgpr) + ": " +round(d,2)):padright(terminal:width) at (0, sgp).
- set sgp to sgp + 1.
- }.
- function sgt {
- parameter l. parameter d.
- If l:length > sgpr set sgpr to l:length.
- print (l:padleft(sgpr) + ": " +d):padright(terminal:width) at (0, sgp).
- set sgp to sgp + 1.
- }.
- //lock sgtwr to ship:availablethrust/ship:mass/body:mu*body:position:sqrmagnitude.
- list engines in sgengines.
- function sgfueltime {
- set sgtotal to 0.
- for sge in sgengines set sgtotal to choose sgtotal+sge:consumedresources["liquid fuel"]:fuelflow if sge:consumedresources:haskey("liquid fuel") else 0.
- return choose ship:liquidfuel/sgtotal if sgtotal > 0 else -1.
- }
- function ChangeTargetAnomaly { parameter name. set as to addons:scansat:getanomalies(body). set closest to as[0]. for anomaly in as if anomaly:name:contains(name) set closest to anomaly. set sgtgt to closest:geoposition. set tarname to closest:name. }
- function ChangeTargetExact { parameter name. set as to addons:scansat:getanomalies(body). set closest to as[0]. for anomaly in as if anomaly:name = name set closest to anomaly. set sgtgt to closest:geoposition. set tarname to closest:name. }
- Function ChangeTargetGeoPosition { parameter geo. parameter name is "geoposition". set sgtgt to geo. set tarname to name. }
- Function ChangeTarget { parameter targetname. set target to targetname. set sgtgt to target:geoposition. set tarname to Target:name. }
- Function ChangeTargetPlace {
- parameter placename.
- if not (defined(places)) set places to readjson("0:/json/" + body:name + ".json").
- ChangeTargetGeoPosition(places[placename]).
- set tarname to placename.
- }
- function ChangeTargetNextAnomaly {
- set as to addons:scansat:getanomalies(body).
- if as:length > 0 {
- set alength to as:length.
- set aindex to 0.
- set closest to as[aindex].
- for i in range(alength)
- {
- set anomaly to as[i].
- if not anomaly:detail and (anomaly:geoposition:distance < closest:geoposition:distance or closest:detail)
- {
- set closest to anomaly.
- set aindex to i.
- }
- }
- set sgtgt to closest:geoposition.
- set tarname to "??? anomaly as[" + aindex + "]".
- } else {
- set sgtgt to ship:geoposition.
- set tarname to "No Anomalies Found".
- }
- }
- if defined(tgt) if(tgt:typename = "Boolean") ChangeTargetNextAnomaly().
- if defined(tgt) and defined(tarname) {
- set sgtgt to tgt.
- print "using existing variables".
- } else if hastarget {
- set sgtgt to target:geoposition.
- set tarname to target:name.
- } else {
- if defined(tgt) { ChangeTargetGeoposition(tgt). }
- else { ChangeTargetNextAnomaly(). }
- }
- list engines in es.
- function fueltime {
- set total to 0.
- for e in es if e:consumedresources:keys:contains("liquid fuel") set total to total+e:consumedresources["liquid fuel"]:fuelflow.
- return choose ship:liquidfuel/total if total > 0 else -1.
- }
- lock grnddist to vang(sgtgt:position - body:position, -body:position)*constant:degtorad*(body:radius + altitude).
- Lock vstar to -(altitude - sgtgt:terrainheight) / (grnddist / ship:groundspeed).
- lock tareta to grnddist / vdot(ship:velocity:surface, sgtgt:position:normalized).
- On round(kuniverse:realtime * sgf) {
- set sgp to sgfirst.
- sgt("Target", tarname).
- sgd("alt:radar", alt:radar).
- sgd("grnd distance", grnddist ).
- sgd("heading", sgtgt:heading).
- sgd("bearing", sgtgt:bearing).
- sgd("eta minutes", tareta/60).
- //if(es:length > 0) { sgd("FuelTime", fueltime()/60). }
- sgd("VS", verticalspeed).
- sgd("fuel", ship:liquidfuel).
- sgd("VS tar", vstar).
- sgd("EC", ship:electriccharge).
- sgd("Fuel Time", sgfueltime()/60).
- sgd("lat", ship:geoposition:lat).
- sgd("long", ship:geoposition:lng).
- Print "":padright(terminal:width) at (0,sgp).
- return sggo.
- }
- print "Use ChangeTarget(<Name>) to pick a new destination".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement