Jump to content

BSL:Manual: Difference between revisions

m
a dprint() in this sample code will make the point more clearly
m (fixing WP redirect; other link tweaks)
m (a dprint() in this sample code will make the point more clearly)
Line 629: Line 629:


====fork====
====fork====
If you call a function with "fork" before its name, the code below the function call continues without waiting for the function to return. If you place this sample code in a script and enter "fork_test" on the dev console, you will immediately see the output "int: 3" even though wait_for_a_second() is waiting for a second on its own thread. You can remove the "fork" keyword to see the difference.
If you call a function with "fork" before its name, the code below the function call continues without waiting for the function to return. If you place this sample code in a script and enter "fork_test" on the dev console, you will immediately see the output "int: 3" even though wait_for_a_second() was called before the value of "enemies" was printed to screen. You can remove the "fork" keyword to see the difference.


  func void fork_test(void)
  func void fork_test(void)
Line 647: Line 647:
  {
  {
     sleep(60);
     sleep(60);
    dprint("Done waiting.");
  }
  }