Other great resources: Official JS API docs, Scripting Forum

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 7 Next »

Uncertain future

It's not certain whether this function will change or be deprecated in future releases, so use with care.

Overview

Register a function to be called when a game object gets destroyed.

This is incredibly useful because you can use it on objects owned by other players, and even destroyable features like trees.

Your function will be triggered immediately before the game object is removed from the map.

To detect when your own objects are destroyed, it's easier to use eventDestroyed() because it avoids having to bind to individual objects.

Availability

3.1 Beta 1 and above.

Syntax

bind(functionName,gameObject);

Parameters

ParameterTypeMandatoryDescriptionGame version
functionNameString(tick)The name of the function that should be called immediately before the gameObject is destroyed.3.1 Beta 1
gameObjectDroid object,
Structure object,
Feature object
(tick)Any game object, such as a droid, structure or feature.3.1 Beta 1

Return value

ValueTypeDescriptionGame version
undefinedUndefinedIndicates the bind was successful.3.1 Beta 1
<error>ErrorIndicates there was a problem (did you remember to specify functionName as as a string?)3.1 Beta 1

Example

Do something when someObject is destroyed
function certainDeath(gameObject) {
  // do stuff
}
 
bind("certainDeath",someObject); // where someObject would be a droid, structure or feature object

See also

 

  • No labels