NetLogo Help: every

### every1.0

#### every number [ commands ]

Runs the given commands only if it's been more than number seconds since the last time this agent ran them in this context. Otherwise, the commands are skipped.

By itself, every doesn't make commands run over and over again. You need to use every inside a loop, or inside a forever button, if you want the commands run over and over again. every only limits how often the commands run.

Above, "in this context" means during the same ask (or button press or command typed in the Command Center). So it doesn't make sense to write `ask turtles [ every 0.5 [ ... ] ]`, because when the ask finishes the turtles will all discard their timers for the "every". The correct usage is shown below.

    every 0.5 [ ask turtles [ fd 1 ] ]
    ;; twice a second the turtles will move forward 1
    every 2 [ set index index + 1 ]
    ;; every 2 seconds index is incremented

See also wait.

Take me to the full NetLogo Dictionary