General

Button Script to "Select Next Switch"

Started by SBPBK on .

Sign in or create an account to join the conversation.

3 posts

Topic starter
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
I would do it like that, maybe there's a simpler solution:
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
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