Page 1 of 1

Button Script to "Select Next Switch"

Posted: 02 Oct 2013 13:57
by SBPBK
Hi,

I am trying to script a button to select the next switch of a Switches object.

Under the Switches object, I am using this script:

ON EXPRESSION: Button.x is greater than 0
firstof(x=Switches.x +1);

I realize my math is off because upon button execution it selects ALL of the switches. Do I need to use a fraction rather than a 1? Not exactly sure about the theory behind the math for this instance, any help or clarification with this would be much appreciated!

Cheers

Re: Button Script to "Select Next Switch"

Posted: 02 Oct 2013 20:22
by Phil999
I would do it like that, maybe there's a simpler solution:

Code: Select all

decl n=firstof(Switches.x);//get the current position

Switches.x=fill(Switches.x,0,sizeof(Switches.x)); //reset

Switches.x=replace(Switches.x,1,n+1);//set the next position

Re: Button Script to "Select Next Switch"

Posted: 06 Oct 2013 12:36
by SBPBK
Works beautifully!

Phil999, I really appreciate your help! You have helped me by responding to several of my posts and I've also read your responses to questions of mine that I've had that were already asked/answer on the forum. A big thanks to you and the rest of this amazing Lemur community. :mrgreen:

Cheers