Is there a way to turn off a switch and not trigger it

Discuss Lemur and share techniques.
Post Reply
mh175
Newbie
Posts: 23
Joined: 06 Oct 2012 16:42

Is there a way to turn off a switch and not trigger it

Post by mh175 »

Is there a way to turn off a switch but not necessarily trigger the script attached to its off state?

I want to have two switches, but only one can be on at any time (similar to radio mode). If I press one switch the other switch turns off. My problem is that each switch has a script that is triggered when the switch reaches zero and I don't necessarily want this script triggered when the switch has changed state.

In essence what I am asking to do is to have a switch only trigger its script if it is literally PRESSED, and not if it is turned on or off by an external script.
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Is there a way to turn off a switch and not trigger it

Post by Softcore »

Lets say our two switches are Switch1 and Switch2. Create an "if" statement at the script of each switch (the one attached to the "off" state) so that if the "other" switch is on, the script wont be executed.

For example, in Switch1

Code: Select all

if (Switch2.x==1) return;
//the rest of the script you already have
In Switch2

Code: Select all

if (Switch1.x==1) return;
//the rest of the script you already have
Softcore
Regular
Posts: 1613
Joined: 04 Nov 2012 08:34

Re: Is there a way to turn off a switch and not trigger it

Post by Softcore »

BTW this case, I think, completely justifies the need for "z" expression in Pads and Switches objects!
mh175
Newbie
Posts: 23
Joined: 06 Oct 2012 16:42

Re: Is there a way to turn off a switch and not trigger it

Post by mh175 »

Thanks! Like 2 seconds after I posted this it hit me to use the "return" command. Der.

Yes a z variable would make this very easy!

Thanks again.
shanekoss
Newbie
Posts: 23
Joined: 27 Jun 2012 13:27

Re: Is there a way to turn off a switch and not trigger it

Post by shanekoss »

another good way around this is to use a timer to block output of an object unless you've physically pressed it.
Attachments
timertest.jzml
(1.94 KiB) Downloaded 81 times
Post Reply