Add sensor button, fix sensor code.
This commit is contained in:
@ -45,3 +45,22 @@ function CreateCircularizationNode {
|
||||
|
||||
return n.
|
||||
}
|
||||
|
||||
// function PredictGeo {
|
||||
// parameter t.
|
||||
|
||||
// local pos is PositionAt(SHIP,t).
|
||||
// local rDir is VDOT(SHIP:BODY:NORTH:FOREVECTOR,SHIP:BODY:ANGULARVEL). //the number of radians the body will rotate in one second (negative if rotating counter clockwise when viewed looking down on north
|
||||
// local dT is t - TIME:SECONDS.
|
||||
// local geoPos is SHIP:BODY:GeoPositionOf(pos).
|
||||
// local drift is rDir * dT * CONSTANT:RADTODEG.
|
||||
// local long is Mod(geoPos:LNG + drift, 360).
|
||||
// if long < -180 {
|
||||
// set long to long + 360.
|
||||
// }
|
||||
// if long > 180 {
|
||||
// set long TO long - 360.
|
||||
// }
|
||||
|
||||
// return LatLng(geoPos:LAT, long).
|
||||
// }
|
||||
|
@ -24,5 +24,31 @@ function ReadSensor {
|
||||
if not sList:HasKey(s) {
|
||||
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
||||
}
|
||||
return s:DISPLAY:TOSCALAR.
|
||||
|
||||
if not sList[s]:ACTIVE {
|
||||
sList[s]:Toggle().
|
||||
}
|
||||
|
||||
// UGH, this appears to be the only way to do this.
|
||||
local ret is -1.
|
||||
if s = "PRES" {
|
||||
set ret to SHIP:SENSORS:PRES.
|
||||
}
|
||||
if s = "TEMP" {
|
||||
set ret to SHIP:SENSORS:TEMP.
|
||||
}
|
||||
if s = "ACC" {
|
||||
set ret to SHIP:SENSORS:ACC:MAG.
|
||||
}
|
||||
if s = "GRAV" {
|
||||
set ret to SHIP:SENSORS:GRAV.
|
||||
}
|
||||
if s = "LIGHT" {
|
||||
set ret to SHIP:SENSORS:LIGHT.
|
||||
}
|
||||
|
||||
// turn off the sensor when we're done with it
|
||||
sList[s]:Toggle().
|
||||
|
||||
return ret.
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ function Hover {
|
||||
function alignForHover {
|
||||
if ReadSensor("PRES") = 0 {
|
||||
// if we're in a vacuum, align with retrograde for smoother horizontal control.
|
||||
lock STEERING to SHIP:SRFRETROGRADE.
|
||||
lock STEERING to LookDirUp(SHIP:SRFRETROGRADE:FOREVECTOR, SHIP:FACING:TOPVECTOR)..
|
||||
print "Aligning with retrograde.".
|
||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 0.1.
|
||||
if done {
|
||||
@ -55,7 +55,7 @@ function alignForHover {
|
||||
}
|
||||
} else {
|
||||
// ... otherwise just align vertically.
|
||||
lock STEERING to SHIP:UP.
|
||||
lock STEERING to LookDirUp(SHIP:UP:FOREVECTOR, SHIP:FACING:TOPVECTOR)..
|
||||
print "Aligning vertical.".
|
||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
||||
if done {
|
||||
|
Reference in New Issue
Block a user