Hi
I trying to create a DIY counter system (count 4, 6, 8 ticks, then reset). I’ve spent all morning going through the tutorial and posts here, without finding a solution. I think I may have posed a similar question, and the solution involved tick_reset (?) but I can’t find it
This works, but only once and then sticks at zero. Some basic misunderstanding of how if logic works perhaps?
live_loop :counter do
idx = tick
if idx >= 6; idx = 0; idx = idx; end
puts idx
sleep 0.5
end
PD-Pi
Yeh, sorry for the noise, I believe this is correct (it doesn’t generate TWO ticks, right?)
live_loop :counter do
idx = tick
if idx >= 5; tick_reset; idx = idx; end
puts idx
sleep 0.5
end
1 Like
Not sure what you want but what about this?
live_loop :tick_test do
tick(step: 2)
print look
print look(offset: -1)
tick_reset if look > 8
sleep 1
end
1 Like
Yes, much more concise thanks, and good to learn about tick(offset:) too.
PD-Pi
Or you could just do this:
live_loop :resetcounter do
resetcounter = tick % 8 #or whatever the max count is
puts resetcounter
sleep 0.25
end
1 Like