// we rebuild the sensor list with every invocation, because things change function buildSensorList { local sList is Lexicon(). list SENSORS in SensorList. for s in SensorList { if not sList:HasKey(s:type) { sList:add(s:type, s). } } return sList. } function HasSensor { parameter s. local sList is buildSensorList(). return sList:HasKey(s). } function ReadSensor { parameter s. local sList is buildSensorList(). if not sList:HasKey(s) { return -1. // TODO: is -1 an impossible result for all sensors? I suspect not... } 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. }