Fix sensor code.
This commit is contained in:
parent
2a61dc6777
commit
f5e80f3687
|
@ -4,7 +4,9 @@ function buildSensorList {
|
||||||
local sList is Lexicon().
|
local sList is Lexicon().
|
||||||
list SENSORS in SensorList.
|
list SENSORS in SensorList.
|
||||||
for s in SensorList {
|
for s in SensorList {
|
||||||
sList:add(s:type, s).
|
if not sList:HasKey(s:type) {
|
||||||
|
sList:add(s:type, s).
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return sList.
|
return sList.
|
||||||
}
|
}
|
||||||
|
@ -22,5 +24,5 @@ function ReadSensor {
|
||||||
if not sList:HasKey(s) {
|
if not sList:HasKey(s) {
|
||||||
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
return -1. // TODO: is -1 an impossible result for all sensors? I suspect not...
|
||||||
}
|
}
|
||||||
return sList[s].
|
return s:DISPLAY:TOSCALAR.
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ function Hover {
|
||||||
}
|
}
|
||||||
|
|
||||||
function alignForHover {
|
function alignForHover {
|
||||||
if ReadSensor("pres") = 0 {
|
if ReadSensor("PRES") = 0 {
|
||||||
// if we're in a vacuum, cancel all velocity first...
|
// if we're in a vacuum, align with retrograde for smoother horizontal control.
|
||||||
lock STEERING to SHIP:SRFRETROGRADE.
|
lock STEERING to SHIP:SRFRETROGRADE.
|
||||||
print "Aligning with retrograde.".
|
print "Aligning with retrograde.".
|
||||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 0.1.
|
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:SRFRETROGRADE:FOREVECTOR) < 0.1.
|
||||||
|
@ -54,7 +54,7 @@ function alignForHover {
|
||||||
return.
|
return.
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// ... otherwise just cancel vertical velocity
|
// ... otherwise just align vertically.
|
||||||
lock STEERING to SHIP:UP.
|
lock STEERING to SHIP:UP.
|
||||||
print "Aligning vertical.".
|
print "Aligning vertical.".
|
||||||
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
wait until done or VAng(SHIP:FACING:FOREVECTOR, SHIP:UP:FOREVECTOR) < 1.
|
||||||
|
@ -76,6 +76,6 @@ function restoreControl {
|
||||||
unlock THROTTLE.
|
unlock THROTTLE.
|
||||||
unlock STEERING.
|
unlock STEERING.
|
||||||
SAS on.
|
SAS on.
|
||||||
print "Stabilized operation ended. Returning control to pilot.".
|
print "Done.".
|
||||||
set done to false.
|
set done to false.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user