Living 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 your living object 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 living object and may be referenced by other scripts for the same living object.

// Living Samples - Base Code
function onHeartbeat(deltaTime) {
    // Add code that should be executed every time the living object has a
    // heartbeat. A heartbeat is roughly 0.5 seconds, but this time can vary a
    // little depending on how complex the script is.

function onCreate() {
    // This method is called when the living object is created for the very
    // first time. This will only be called once per lifetime of a living object.

function onSuspend(dataStore) {
    // If a living object is no longer near any players or the game servers are
    // down, the living objects will be suspended in their 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 a living object that has been suspended, that living
    // object will be resumed to continue about its business. This is the time to
    // restore any information that was saved during onSuspend.

function onMessage(sender, message) {
    // This method is called when another living object has sent a message to this
    // living object. This could be from a player or from another scripted computer
    // character.