script ScriptName { }

Scripts are sequences of control statements that control the flow of the game, direct game objects, do calculations, perform procedures, or handle routines. They may be started when some event is triggered (each event is really just some condition attached to an unnamed script), or they can be started or called by another script. If a script is assigned to a handler, it may be called or started by the interpter.

A script may have any number of parameters, and may or may not return an explicit value.


script example1 // also no parameters
{
     // there is no return-statement, so
     // 'return 0' is implied
}

script example2() // also no parameters
{
     return 5; // explicitly returns 5  
}

script example3(param1, param2) // two parameters
{
     start {
          // inside these braces is another
          // script; but one without a name
     }

     return; // returns 0 implicitly
}

Scripts declared in a scene overload game scripts of the same name whenever the user is in that scene. So, even if a script is called from a game script, it will call the scene version. This is very handly for overriding game logic with a special case in any scene where it matters.

A script may be assigned to a handler, such as the game input handler, so that it will be responsible for handling game input. It it important that the script satisfies all the requirements of a particular kind of handler, or the interpreter will likely crash!

See Also...