BSL:Manual: Difference between revisions

220 bytes added ,  22 October 2022
m
→‎sleep: mentioning how "sleep" was BWest's main tool for event timing (used over 1700 times!); also confirming that the 'f' doesn't do anything
m (a dprint() in this sample code will make the point more clearly)
m (→‎sleep: mentioning how "sleep" was BWest's main tool for event timing (used over 1700 times!); also confirming that the 'f' doesn't do anything)
Line 288: Line 288:


====sleep====
====sleep====
You can also delay execution of a script using "sleep", passing it a number in sixtieths of a second:
You can also delay execution of a script using "sleep", passing it a number in sixtieths of a second. This keyword was heavily used by Bungie West and could be considered their primary method of executing events with the right timing. Its usage is simple:


  sleep(60); # pause execution of BSL at this point for one second
  sleep(60); # pause execution of BSL at this point for one second


Sometimes you will see in the original scripts a call to sleep with a 'f' character before the sixtieths of a second like this: sleep(f60), but apparently there is no difference by using this extra character.
In Oni's level scripts, you will often see a call to "sleep" with an 'f' preceding the sixtieths of a second like this: "sleep(f60)". There is no change in functionality when using this character (it may be a relic of an earlier version of "sleep"), so you can leave it out.


Note that you cannot have a sleep statement in a function that returns a value, probably to avoid variables being changed at unexpected times.
Note that you cannot have a sleep statement in a function that returns a value, probably to avoid variables being changed at unexpected times.