Enter-Statement


enter SceneName;

Enter causes the interpreter to change to a new scene.

When the scene is changed, all running scripts with the killOnExit property set to true are killed, the objects' resources of the current scene are deallocated, the objects' resources of the new scene are allocated, and the enter event for the new scene is started, along with the objects' initialization scripts.

Start-Statement


     start scriptName;
     start scriptName(parameters...);
     start { }

The start-statement starts executing a script independently from the script that is currently executing. Statements within the code block in the second version above cannot access local variables outside of their code block. In both cases, the existing script continues, and starts the new script simultaneously. (Actually, the script does not begin executing until the existing script delays or returns, but the new script is guaranteed to start before the next interpreter cycle.)

Example

Suppose there are two objects, called Fred and Bob, and they must both walk at the same time.


start {
     Bob.walk(280, 430);     
}
Fred.walk(300, 400);

Delay-Statement


     delay;
     delay expression;

Delay causes the script to sleep for a number of cycles, so that other scripts may be executed. The expression is evaluated only once, and if it is omitted, it is assumed to be a one-cycle delay. A delay of zero or less has no effect.

Example

Delay can be used for simple delays, or it can be used in more complex ways. Here's how to produce the effect of random strobing of a bug zapper.


killOnExit = true;     // kill when scene is exited                        
BUGZAPPER:             // select an object to work with
autoAnimate = false;   // turn off automatic frame flipping
loop {                 
     frame = 0;         // picture of light when off
     delay randomRange(100, 300);
     frame = 1;         // picture of light when on
     delay;             // show zapper lit for one cycle
}

Warning: If an infinite loop exists without a delay-statement inside, the game could seem to freeze, because the script never returns control to the interpreter.

Return-Statement


     return expression;
     return;

Return halts execution of the current script and returns to the caller if the script was called, or ends execution if the script was started with the start-keyword (or is the body of an event).

If no return value is specified, the script will return zero.

See Also...