From 41a756a6ba81ede0faf1e280452b4f79c9aaa6aa Mon Sep 17 00:00:00 2001 From: mfranz Date: Wed, 13 Dec 2006 16:15:27 +0000 Subject: [PATCH] light class: make the first time-value always "on", even for odd numbered light pattern. This is more robust and doesn't need the reinit listener. --- Nasal/aircraft.nas | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Nasal/aircraft.nas b/Nasal/aircraft.nas index 6acad0568..99a823288 100644 --- a/Nasal/aircraft.nas +++ b/Nasal/aircraft.nas @@ -205,13 +205,11 @@ light = { m.continuous = 0; m.lastswitch = 0; m.switchL = setlistener(m.switchN, func { m._switch_() }, 1); - m.reinitL = setlistener("/sim/signals/reinit", func { m.cont(); m.blink() }); return m; }, # class destructor del : func { removelistener(me.switchL); - removelistener(me.reinitL); }, # light.switch(bool) -> set light switch (also affects other lights # that use the same switch) @@ -257,7 +255,7 @@ light = { _loop_ : func(id) { id == me.loopid or return; - me.stateN.setBoolValue(!me.stateN.getBoolValue()); + me.stateN.setBoolValue(me.index == 2 * int(me.index / 2)); settimer(func { me._loop_(id) }, me.pattern[me.index]); if ((me.index += 1) >= size(me.pattern)) { me.index = 0;