Nasal Loops: Difference between revisions

Jump to navigation Jump to search
Line 247: Line 247:


<syntaxhighlight lang="nasal">
<syntaxhighlight lang="nasal">
var mt_loop_example = func {
var loopExample = func {
     if (some_condition) {
     if (someCondition) {
         mt_loop_exampleTimer.restart(0.1); # Adjust the timer frequency (ms)
         timer.restart(0.1); # Adjust the timer frequency (ms)
     }
     }
      
      
     if (finished) {
     if (finished) {
         mt_loop_exampleTimer.stop(); # Cancel the timer. Timer can be started again later.
         timer.stop(); # Cancel the timer. Timer can be started again later.
     }
     }
};
};


mt_loop_exampleTimer = maketimer(0.25, mt_loop_example);
var timer = maketimer(0.25, loopExample);
mt_loop_exampleTimer.simulatedTime = 1; # Use simulated time, as maketimer defaults to using wallclock time and continues during pause.
timer.simulatedTime = 1; # Use simulated time, as maketimer defaults to using wallclock time and continues during pause.
mt_loop_exampleTimer.start();
timer.start();
</syntaxhighlight>
</syntaxhighlight>


1,314

edits

Navigation menu