Environment Samples - Base Code

The sample code below shows all possible methods that may be defined. You may define one or many of the methods to cause the environment to do something. Please note that not declaring any of the functions below would result in code that cannot be called and, therefore, ignored.

Any global variables defined will not be strictly global. Instead, these variables become global only to the current environment and may be referenced by other scripts for the same environment object.

// Environment Samples - Base Code

function onHeartbeat(deltaTime) {
    // Add code that should be executed every time the environment has a
    // heartbeat. A heartbeat is roughly 0.5 seconds, but this time can vary a
    // little depending on how complex the script is.
    //
    // It may not make sense why an environment has a heartbeat... Just think
    // of it as a way to let the environment check the state of things periodically.
}

function onEnter(living) {
    // When any living object (player or computer) enters the space occupied
    // by the current environment object, this method is called.
}

function onMove(living) {
    // When a living object has moved, this method is called.
}

function onLeave(living) {
    // When a living object has left the room, this method is called.
}

function onSuspend(dataStore) {
    // If an environment is no longer near any players or the game servers are
    // down, the environment object will be suspended in its current state. This
    // is the time to store any information that should be restored when
    // onResume is called at a later point in time.
}

function onResume(dataStore) {
    // If a player is close to an environment that has been suspended, that 
    // environment will be resumed to continue about its business. This is the 
    // time to restore any information that was saved during onSuspend.
}