Cycle Between 3 Options

SOLVED
I ended up putting an XOR Gate between the filter and each of the numbers (2 gates total) to “purify” the outputs. Works great.


I’m trying to make it so that when my player clicks on a space it cycles between three different options. Each click would attach a different sprite to the square and un-attach the previous one. I thought I had it all figured out, but I think I must not fully understand how the “Filter” or the “Number” block work. I’ll paste my solution below. What I was trying to do was have it so that when the player clicked, the primary Number on the bottom cycled between 0, 1, 2, and 3 and then went back to 0. This Number would be output to each of the three Filters I have to the right.

What actually happens is that every time I click, the Filter on the top sends both Pass and Fail and the “Add 1” Number for some reason pushes to the “Primary” Number and sets it to 4. It is then immediately set back to Zero by the “Set to Zero” Number. Help please?

1 Like

Instead of using Filters (nothing wrong with that), you can put it all into one equation:

Sorry on phone, otherwise I would have checked out what’s wrong with your example.
The formula is:
A+=1;A%4

The first half adds 1 to ‘A’, the second half (the modulus operator) makes sure that it will never go above 3, in that case it resets it to 0.

2 Likes

Hey @Grekin,

This doesn’t exactly help you (yet), but just FYI - there is a new behavior block called a Router that will handle this case (and a few others) automatically in the upcoming release. It’s not available yet, but will be soon.

4 Likes