1
0
Fork 0

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.
This commit is contained in:
mfranz 2006-12-13 16:15:27 +00:00
parent 923f2b7299
commit 41a756a6ba

View file

@ -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;