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 5 Current »

Determine if a droid object is a transporter.

 

Notes

The code snippet below adds an isTransporter() function that returns true if the passed in object is a transport.

Code

var transportTypes = [
	DROID_TRANSPORTER,
	DROID_SUPERTRANSPORTER
]
 
// Determine if an object is a transporter
this.isTransport = (typeof enumCargo == "function")
	? function(obj) { // WZ 3.2+
		return obj.hasOwnProperty("cargoCapacity");
	  }
	: function(obj) { // WZ 3.1
		return obj.type == DROID && transportTypes.indexOf(obj.droidType) != -1;
	  }

Example

function eventAttacked(victim, attacker) {
	if ( isTransport(victim) ) {
		// do stuff specific to transport attack
	}
}
Availability 3.1 B5+

Requires:

  • Warzone 3.1 Beta 5 and above.
  • Earlier versions had problems with transporters.

See also: Working with Transports

Contents

Jump to:

Scripting: Droids

Related objects:

Constants:

  • .action – what action is the droid doing?
  • .droidType – what category of droid is it?
  • .order – what is the droids order?

Create them:

Organise them:

List or count them:

Tell them what to do:

How to's:

Transfer them between players:

Find out what's happening to droids:

Remove them:

Player Initialisation:

 

  • No labels