I’m trying to build a simple slideshow where one keyboard button will move you left to right through the slides and another will move you right to left. I can manage to move one direction by using a counter and switch nodes but the logic to move back through the slides eludes me.
Sometimes a little bit of python is easier for these kinds of tasks. If drop down a keyboard in DAT, and a constant CHOP, try replacing your onKey callbacks with this:
The idea would be that the right arrow key counts up, and the left arrow key counts down. With a little more python you could add in a reset function for another key press, and also set limits for how far it would count up or down.
Here’s a functioning example. Your left and right arrow keys add and subtract from the value0 in constant1.
Learning some python in the context of Touch is pretty important - in my opinion - if you want to make meaningful progress. There’s a set of tuts up here to help you get your feet wet in that process if you’re interested: matthewragan.com/teaching-resou … hdesigner/
Hi! just reading this in 2023 but posting the answer if anyone searches for it, using two keys for counting up and down is pretty straightforward just using nodes, without python!
First you need to get your two keys with your keyboard CHOP (here to get the arrow keys you can just type “left” and “right”), then a count CHOP that will count the number of times that each keys have been pushed. Last step is to put a math CHOP, set “combine channels” to “substract” and you’re done!
If the order is reverse either change the order of left and right in the keyboard in CHOP, or multiply by -1 in the math CHOP.
I hope that someone that don’t like using python like me can find this useful, cheers!
another optimization could be to use the 3rd Input of the Count CHOP: “Increment Value”. So depending on which key you press, you could pass in a 1 or a -1 automatically doing it all in a single Count CHOP.