Getting two sticky-pistons to pull eachother, a piston-train, isn't anything new but the pistons and their timing in 1.3 are and there has been alot of QQ-ing on the Minecraft-forums about how bad they are and that Jeb should bring back the old pistons we all know. I, for one, not only welcome out new 1.3-pistons but have also made a small mini-game out of them.
A two-player tug-o-war. The players stand on the diamond or emerald area and press a button to make the piston-train take one step towards them. When the pistons reach the blue wool they will trigger a bud-switch that shoots out a reward to the player.
But lets forget about this part for now. We can talk about the weird behaviour of dispensers another time. Lets focus on what makes the pistons tick.
This is what drives the pistons. Two 1-tick pulse generator, the red and the blue part, with a 2-tick delay between them. When you press the button you will get two very short pulses.
And here is the 1.000.000-emerald question. Why? Why do they make the pistons move? And why do they move towards the source of the pulse?
I can't say that I'm a 100% sure myself, I haven't looked into the code for Minecraft but my guess is that it works something like this...
When the first redstone pulse comes what happens is that all the redstone dust is updated first and all other redstone "devices" connected to it is put on a stack of things to update later.
Which means that when the last redstone dust (at the blue wool) has been updated it traces back to find the last "device" it should update next, in this case is the piston at the green wool which gets extended.
The piston at the red wool is also checked, but since there is a piston that is extended, or rather, in the process of being extended, nothing will happen.
So we get something like in the picture above. And since the redstone is only powered for 1-tick the piston won't pull the other piston back, but will drop it.
At the next pulse this will happen. The piston at the green wool won't extend, even if it is checked first since it is in the process of being retracted. But the piston at the yellow wool will extend since it no longer have an extended piston blocking it's path.
When the power is off, it will pull the other piston towards itself. And the piston-train has taken one step closer to the goal. :)
The funny things is that this will work the same way if you send the signal from the other end. No matter which end you send the signal from the piston train will walk towards the source. Simply place another 2-short-pulses generator at the other and and you have a tug-o-war game.
I came up with this while I was playing around trying to make a kind of "hedge-timmer" to cut sugar cane but it just got too big and ugly to be any fun to show so I ended up with this mini-game instead. I'd LOVE to see someone come up with some other use for this. Maybe as a counter or something to move mobs/items around?
Hmmm, yeah, I guess this might not have been the easiest how-to I've written...so...anyway... Free cookies at /warp rsplayground ! Yay!