Najova

DocsGuides

Time

Scripts can wait, run something later, or run something again and again. A wait pauses only the script that waits.

timers.naja
$print[Oven on]
$after[0.3]
  $print[Ding! Bread is ready]
$endafter
$let[checks;0]
$every[0.1;check]
  $set[checks;$get[checks] + 1]
  $print[Check $get[checks]: still baking]
  $if[$get[checks] == 2]
    $call[check.Stop]
  $endif
$endevery
najova run timers.naja
Oven on
Check 1: still baking
Check 2: still baking
Ding! Bread is ready
  • $wait pauses the script for some seconds, then goes on.
  • $after runs its block once, later. The script carries on at once.
  • $every runs its block again and again. Give it a link name to stop it with $call[name.Stop].

najova run keeps going while anything is still waiting, then ends by itself.