We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi all,
I have a small issue I hope.
I have a for loop which in it there's also a conditional which happens only once (kind of trigger) and I have a counter which when it reaches 0 I need it to trigger another conditional. I need the counter to start going down when there's a trigger, the problem is that the counter only goes down by 1 every time it's triggered. I tried moving the counter-- around in the code but with no luck, can some one help me out please, thanks!
for (int i = 0; i < cols; i++) {
for (int j = 0; j < rows; j++) {
int index = i + j * cols;
//println(j);
grid[index].display();
//CODE FOR SENSORS (hopefully)
println(counter);
if (grid[index].on == false && sensor && grid[index].on == false && sensorIndex == grid[index].cellIndex) {
grid[index].on = true;
counter--;
if (counter <=0) {
if (index > cols) grid[index-cols].on = true;
if (index < grid.length - cols) grid[index+cols].on = true;
if (index < grid.length-1 && i != 5) grid[index+1].on = true;
if (index > 0 && i != 0 ) grid[index-1].on = true;
}
//println(index);
sensor = false;
} else if (grid[index].on == true && sensor && grid[index].on == true && sensorIndex == grid[index].cellIndex) {
grid[index].on = false;
if (index > cols) grid[index-cols].on = false;
if (index < grid.length - cols) grid[index+cols].on = false;
if (index < grid.length-1) grid[index+1].on = false;
if (index > 0) grid[index-1].on = false;
sensor = false;
}
}
}
Answers
https://Forum.Processing.org/two/discussion/23846/time-delay-in-python-mode#Item_11
http://Bl.ocks.org/GoSubRoutine/1a0d21828319cf18fecf44101764bd60
Thanks for the links.
Excuse my ignorance but from where can I download the library:
Can't figure out how to make work the code you gave.
class
Countdown code there.class
Countdown. B-)Had tried it but saved it as .pde instead of .java.
Thanks for the clarification.
Yep, Countdown's file needs to be suffixed w/ ".java" b/c it is an actual Java code. ~O)
".pde" suffixed files are "Processing" code instead. :P
yeaaaah I know the extensions haha, just didn't figure out how to make it work as had never did it. Again, thanks a lot my friend :)
Maybe you can help me out with this other issue since you're that good hehe :p