This guide, as all other counter computing/efficiency guides, aims to make block code almost obsolete using counters.
Concept
I will have a system, call it system S. This system will contain counters A and B, both of which I wish to swap their values. What do I mean by this? I want A to become B, and B to become A. How will we do this?
Practice
Place down a trigger(call it N). This trigger will start our entire system. Make it transmit on channel “start swap”.
Place down another trigger(call it M). M will trigger and activate on channel “start swap”, and will broadcast on “trigger a”. It will also trigger on “trigger a”.
Counter A(mentioned in concept) will decrease on “trigger a”, and will have a target of 0. Counter C will increase on “trigger a”, and will have a target of 0.
When A reaches target → M deactivates. Use a channel for this, “target = A”, and have a third trigger(call it L) that will trigger on “target = A” and activate on that channel.
Have trigger L increment A and decrement B(mentioned in concept). Have L be recursive using channel “trigger b”.
B will have a target of 0, when reached, deactivate L. Use channel “target = B”.
K should increment counter B and decrement C. K will broadcast on “trigger c” and receive on “trigger c”.
On target reached by C → deactivate K. Use channel “target = C”.
So what I’m getting from this is that there’s a trigger loop running for each counter that flows into the other. The trigger loop stops when the counter is 0.
My main question would be: What would you need to do if you wanted to have a set target value for the counters A and B? Would you use another counter?
This is mainly to swap the values. If you want counter A and B to some number specific, you’d add two counters with the values to swap to. (I’m not sure if I understood what you meant)
@VALUEX, I did some testing and I figured out this could be done with only three triggers.
The triggers have to loop themselves and then the counters have to broadcast from trigger to trigger until the entire thing is done.