buildDroid()

(info) Other great resources: Official JS API docs, Scripting Forum

buildDroid()

Instruct a factory to build a droid...

 

Syntax

For warzone 3.1 and earlier:

WZ v3.1
buildDroid(factory, name, body, propulsion, "", droidType, turret[, turret2[, turret3]]);

In master / warzone 3.2 and later, the droidType parameter is no longer required (it is determined automatically in order to fix bug #3133):

WZ v3.2+
buildDroid(factory, name, body, propulsion, null, null, turret[, turret2[, turret3]]);

Parameters

Parameter

Type

Mandatory

Description

Game version

factory

Structure object

The factory in which the droid should be constructed. You must own this structure!

The structure's .status must be BUILT, and it must be idle (not currently building anything).

The structure's .stattype must be the correct type of structure for the droid's propulsion type:

3.1 Beta 1

name

String

The name to give the droid, for example "Bob the Droid".

It's useful to base the name on the purpose of the droid, for example "AT" for droids that are designed to attack tanks. You can then quickly find droids by looking through a list of Droid objects returned by the enumDroid() function.

3.1 Beta 1

body

String

Array of String

The body that your droid will use.

You can quickly find the ID strings for bodies in the online guide - just click any body and look at "Body ID".

If you pass in an array of body types, the first available body in the list will be used.

3.1 Beta 1

propulsion

String

Array of String

The propulsion the droid will use.

If you pass in an array of propulsion types, the first available propulsion in the list will be used.

3.1 Beta 1

droidType

Number (in wz 3.1)

Null (in wz 3.2+)

In warzone 3.1 and earlier, you have to specify the droidType and it must match the type of droid being built:

In Warzone 3.2 and later, pass in null – the function will determine the droid type automatically.

If your script needs to work on both v3.1 and v3.2, specify the droid type (it will be ignored in 3.2) but bear in mind the issues with cyborg engineers and mechanics in Warzone 3.1 (bug #3133) – see examples below.

3.1 Beta 1

Simplified in 3.2

turret

String

Array of String

The turret (weapon, sensor, etc) that will be placed on the droid.

If you pass in an array of turrets, the first available turret in the list will be used.

3.1 Beta 1

turret2

String

Array of String

If the body can handle 2 or more turrets, this parameter can be specified to define the second turret if desired.

If the body can't handle 2 or more turrets, do not specify this parameter.

turret3

String

Array of String

If the body can handle 3 turrets, this parameter can be specified to define the third turret if desired. Note that you must define the second turret (turret2) parameter if you want to define the third turret (turret3).

If the body can't handle 3 turrets, do not define this parameter.

Return value

Value

Type

Description

Game version

true

Boolean

The factory is building you a shiny new droid.

3.1 Beta 1

false

Boolean

Something went wrong - check the logs to find out what.

3.1 Beta 1

<error>

Error

The structure you specified doesn't exist, isn't owned by you, or isn't a factory. Duh!

3.1 Beta 1

Example

Creating cyborg engineers and mechanics - Works in Warzone 3.1 and 3.2
// cyborg engineer buildDroid( borgFactory, "Cyb-Engineer", "Cyb-Bod-ComEng", "CyborgLegs", "", 10, "CyborgSpade" );   // cyborg mechanic buildDroid( borgFactory, "Cyb-Mechanic", "Cyb-Bod-Mechanic", "CyborgLegs", "", 11, "CyborgRepair" );