scripting a pad with a blinking "on" state [SOLVED]

Discuss problems and solutions.
Post Reply
dburns
Newbie
Posts: 25
Joined: 14 Apr 2012 04:31

scripting a pad with a blinking "on" state [SOLVED]

Post by dburns »

Hey Guys,
I'm trying to script a pad to be blinking on and off while "on" and switching to a darker colour when off. I created an expression for the blink which works great if I plug it into the "light=" properties-

blink=sin(time*3)/3+.1+.1

I can use the script below to toggle a pad's light bright and dark -

on expression x rising-
if (!light) light=.8;
else light = 0;

... but the pad is either lit up when on or dark when off. I'm looking for a flashing "on" signal kinda thing. I specifically need to use a pad not a switch. Any help appreciated.
Last edited by dburns on 05 Apr 2017 15:12, edited 1 time in total.
oldgearguy
Regular
Posts: 315
Joined: 02 Nov 2013 11:19

Re: scripting a pad with a blinking "on" state

Post by oldgearguy »

instead of doing this,

on expression x rising-
if (!light) light=.8;
else light = 0;

what about if you defined a global variable called offset and initialized it to 0:
offset = 0;

and changed your blink expression to:

blink=sin(time*3)/3+.1+.1 + offset

and your then expression is:

if (!light) offset = 0; // or whatever value you need to make it bright enough
else offset = -2; // or whatever value you need to make it dark as needed


The idea being that the light property has a range of -2 to +2 and sine() is -1 to +1 so if you add an offset to the equation, you can override whatever sine() produces.
dburns
Newbie
Posts: 25
Joined: 14 Apr 2012 04:31

Re: scripting a pad with a blinking "on" state

Post by dburns »

That's some mighty fine logical thinking. But I couldn't get liftoff. It doesn't seem to me to be toggling. This is so easy to do with a second object, but the whole point is to do it with the one pad only.

I'm wondering how to script something that takes a pad press and sequentially switches between two states. That way i could make "state one = blink" and "state two = off"......somehow.
lABl
Lemur Guru
Posts: 269
Joined: 09 Dec 2011 15:56
Contact:

Re: scripting a pad with a blinking "on" state

Post by lABl »

Hi there,

I've attached an example, you can change a little bit the behavior from these three variables if you wish:

flashMaxLight
pulseRate
pulseWidth


Hope that helps,
Cheers!
Attachments
AB Flash Pad.jzlib
(4.31 KiB) Downloaded 220 times
dburns
Newbie
Posts: 25
Joined: 14 Apr 2012 04:31

Re: scripting a pad with a blinking "on" state

Post by dburns »

Hey IABI, you are bang on. I will study this and try to learn. Thank you so much, I can honestly say I would've never come to this logic on my own.

Thank You again!
Post Reply