Jump to content

BSL:Manual: Difference between revisions

m (lede wording)
Line 667: Line 667:


====schedule ... repeat ... every ...====
====schedule ... repeat ... every ...====
Allows you to schedule a function call to repeat x times at a rate of y ticks. Unused in Oni's scripts, but here's a working example:
Allows you to schedule a function call to repeat ''x'' times at a rate of ''y'' ticks. Unused in Oni's scripts, but here's a working example:


  schedule dprint("Is this annoying yet?") repeat 50 every 20;
  schedule dprint("Is this annoying yet?") repeat 50 every 20;


This is basically equivalent to the following "for" loop in a C-style programming language:
This is equivalent to the following loop in a C-style programming language:


  for (int i = 0; i < 50; i++)
  int i = 1;
do
  {
  {
     print("Is this annoying yet?");
     print("Is this annoying yet?");
     wait(20);
     wait(20);
  }
    i++;
  } while (i != 50);


To create an infinite loop, you can use "0" or a negative number as the repeat value:
To create an infinite loop, you can use "0" or a negative number as the repeat value: