Light script to toggle multiple text objects

Discuss Lemur and share techniques.
Post Reply
SBPBK
Newbie
Posts: 19
Joined: 20 May 2012 04:34

Light script to toggle multiple text objects

Post by SBPBK »

Hi,

I am trying to write a script in the "light box" of text objects to tell them to be visible (set at 0) when a fader is set between a range of CC values (or in some cases set to just one CC value) and to be blacked out (set at -2) otherwise.

My fader is named "f1", I am writing a script such as f1.x==0?0:-2 OR FOR MULTIPLE VALUES f1.x==1||2||3?0:-2 in the "light" box of the corresponding text object. I am basing this off the equation if a then b else C (a?b:c) but so far I am coming up empty handed. Perhaps I am going about this the wrong way or mistaken with my scripting language...

although it doesn't matter on the scripting level, just for the sake of knowing what I'm trying to do: there are 28 text objects that I am trying to have assigned to and essentially toggle their visibility across the CC values 0-107 of a fader but they are NOT mapped to even integers (some are mapped over a range of 3 CC values, some over 4, some over 1, etc.) so I need to be able to have specific control over at which CC values each text object will be visible at.

Any guidance or ideas would be greatly appreciated, cheers! :mrgreen: :ugeek:
dsorlien
Newbie
Posts: 39
Joined: 16 Jan 2012 04:28

Re: Light script to toggle multiple text objects

Post by dsorlien »

Try creating a script in the Fader object. Set execution to: "On Expression", "x", "any". This script will now run anytime the fader is moved.

In the script, do something like this:

Code: Select all

// txt1 is the object we wish to show or hide
// remember that fader.x value ranges from 0.0 to 1.0
show(txt1, x<0.5); // shows txt1 when fader position is less than halfway
If the conditional tests are more complex, I would do something like this:

Code: Select all

// txt1 is the object we wish to show or hide
// assume fader is sending CC messages with value 0 to 127
// and we need to test multiple conditions before setting txt1's visibility
decl vis = 0; // using this as a flag
decl b = floor(x*127); // convert x to integer 0 to 127
if(b==2) vis=1; // test for a specific value
if(b==7 || b==11 || b==13) vis=1; // test for some specific values
if(b>31 && b<64 ) vis=1; // test for a specific range
// add as many tests as needed
show(txt1, vis); // hide or show the text object
SBPBK
Newbie
Posts: 19
Joined: 20 May 2012 04:34

Re: Light script to toggle multiple text objects

Post by SBPBK »

Thanks so much for your help!
Post Reply