Showing 2 changed files with 9 additions and 0 deletions
+7
Nasal/core.nas
... ...
@@ -198,10 +198,14 @@ var deviceClass = {
198 198
 };
199 199
 
200 200
 var powerOff = func {
201
+    foreach (var listener; keys(data.listeners))
202
+        removelistener(data.listeners[listener]);
203
+
201 204
     foreach (var timer; keys(data.timers)) {
202 205
         data.timers[timer].stop();
203 206
         delete(data.timers, timer);
204 207
     }
208
+
205 209
     foreach (var name; keys(flightdeck)) {
206 210
         flightdeck[name].off();
207 211
         delete(flightdeck, name);
... ...
@@ -215,6 +219,9 @@ var powerOn = func {
215 219
         return;
216 220
     }
217 221
 
222
+    if (contains(data.listeners, 'autopower'))
223
+        removelistener(data.listeners.autopower);
224
+
218 225
     foreach (var freq; keys(data.timers))
219 226
         data.timers[freq].start();
220 227
 
+2
zkv1000.nas
... ...
@@ -204,6 +204,8 @@ var zkv1000_init = func {
204 204
     load_multikey();
205 205
     load_nasal();
206 206
     print('zkv1000 loaded');
207
+    if (zkv.getValue('auto-power'))
208
+        data.listeners.autopower = setlistener(zkv.getPath() ~ '/serviceable', zkv1000.powerOn, 0, 0);
207 209
 }
208 210
 
209 211
 var init = setlistener('/sim/signals/fdm-initialized', zkv1000_init, 0, 0);