Index in Switches Script

Discuss Lemur and share techniques.
FineCutBodies
Newbie
Posts:8
Joined:14 Jan 2017 11:55
Location:Los Angeles, California
Contact:
Re: Index in Switches Script

Post by FineCutBodies » 20 Jan 2017 02:51

phase_change wrote:
FineCutBodies wrote: I know it's not working, I just gave it as an example that how good it would be if I could get 'i' as an argument :) So no worry, the first script works well...
I just told you how to make it work, not that it's not working. Create an expression called 'i'.
I know, but that's not solving the problem as 'i' won't be set, but read and its value will be used in the expression not replaced. As I told it was just some kind of pseudo code to demonstrate how good it would be if I could GET 'i' as an argument there. Sorry if it wasn't clear.

Again thanks for the help, it's obvious now it wasn't me who missed something pretty basic like "getCallerSwitchIndex()' or I could get the index as an ARG. And yes there are a couple of workarounds and even when I asked the question I had a working code, just wanted to make sure.

Thx!

FineCutBodies
Newbie
Posts:8
Joined:14 Jan 2017 11:55
Location:Los Angeles, California
Contact:

Re: Index in Switches Script

Post by FineCutBodies » 20 Jan 2017 02:52

oldgearguy wrote:are the switches in the matrix set up as radio buttons? (i.e. - only 1 on at a time?)
If so, you can do an "OnExpression (x) any" and then do a firstof(x) to get the one that is on. firstof() returns the index (0 based) of the first non-null item in an array. If you wanted to do processing for what turned off as well, then this doesn't help too much.
sure that would solve it, but they aren't radio buttons.
oldgearguy wrote:If not (you can have more than one on at a time) then you can still do an "OnExpression(x) any" but you have to save off the array of values into an expression defined outside the script so the info stays around between frames.
Your example above is exactly that and I don't think there's any better shortcut.
Yeah I feel it too. Thanks for your help also!

phase_change
Regular
Posts:114
Joined:31 May 2015 18:45
Location:Austin, TX

Re: Index in Switches Script

Post by phase_change » 20 Jan 2017 06:08

Was thinking about this... maybe could have two expressions that are arrays. When x triggers up, update array to store value as 1 and clear all others. When x triggers down, do the same. Then you could use firstof().
Have you tried turning it off and on again?

Post Reply