Page 2 of 2

Re: Index in Switches Script

Posted: 20 Jan 2017 02:51
by FineCutBodies
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!

Re: Index in Switches Script

Posted: 20 Jan 2017 02:52
by FineCutBodies
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!

Re: Index in Switches Script

Posted: 20 Jan 2017 06:08
by phase_change
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().