ID:167320
 
I dont know if this is the right place to ask, but what is the difference between the spawn and sleep procs?
There is a huge difference. Sleep stops the function in its tracks but spawn does not.
proc/MyProc()
world<<"Let's wait a bit."
sleep(10)
world<<"...a second later"

That outputs "Let's wait a bit." then a second later it outputs "...a second later", obviously.
proc/MyProc()
world<<"Let's wait a bit."
spawn(10)
world<<"Oops! It didn't wait. This shows immediately after."

That example does not wait.

When you use spawn, you give it its own code block and it waits to execute that block and that block only, nothing else.
proc/MyProc()
world<<"This comes up first."
spawn(10)
world<<"This comes up third, a second after the other two."
world<<"This comes up second, immediately after the first."

spawn also ignores the call stack (except for the function that immediately preceeds it) which it was called from, allowing you to have an infinite recursion without crashing.
In response to Loduwijk
thanks