ArcBasicDocs

Spawn

[coroutine =] Spawn FunctionName(parameters)

Parameters

None.

Description

Starts one of the program's functions as a coroutine: a script that runs alongside the rest of the program, pausing whenever it reaches Wait or WaitUntil and carrying on from there later, while everything else keeps going. It gives back an id for StopCoroutine and CoroutineRunning.

A coroutine starts on the next frame: coroutines take their turn each time the main program shows a frame with Flip or waits, so each one moves on a step per frame. Many can run at once, each with its own variables. A coroutine ends when its function returns. A coroutine can be paused in the middle of a line, by a function it calls that waits, so read shared variables again after waiting rather than relying on a value read before.

Example

Spawn.abs
Function Patrol(guard)    Repeat        MoveTo guard, 10, 0 : Wait 2        MoveTo guard, -10, 0 : Wait 2    ForeverEnd FunctionSpawn Patrol(guard1)Spawn Patrol(guard2)

See also