Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Instruct a factory to build a droid...

 

Syntax

For warzone 3.1 and earlier:

Code Block
themeRDark
languagejavascript
titleWZ v3.1
linenumberstrue
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):

Code Block
themeRDark
languagejavascript
titleWZ v3.2+
linenumberstrue
buildDroid(factory, name, body, propulsion, null, null, turret[, turret2[, turret3]]);

Parameters

ParameterTypeMandatoryDescriptionGame version
factoryStructure object(tick)

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
nameString(tick)

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

(tick)

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

(tick)

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+)

(tick)

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

Child pages (Children Display)
alltrue
depthall
page.droidType
excerpttrue

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

(tick)

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

(error)

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.

(question)
turret3

String

Array of String

(error)

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.

(question)

Return value

ValueTypeDescriptionGame version
trueBooleanThe factory is building you a shiny new droid.3.1 Beta 1
falseBooleanSomething went wrong - check the logs to find out what.3.1 Beta 1
<error>ErrorThe structure you specified doesn't exist, isn't owned by you, or isn't a factory. Duh!3.1 Beta 1

Example

Code Block
themeRDark
languagejavascript
titleCreating cyborg engineers and mechanics - Works in Warzone 3.1 and 3.2
linenumberstrue
// cyborg engineer
buildDroid(
	borgFactory,
	"Cyb-Engineer",
	"Cyb-Bod-ComEng",
	"CyborgLegs",
	"",
	10,
	"CyborgSpade"
);
 
// cyborg mechanic
buildDroid(
	borgFactory,
	"Cyb-Mechanic",
	"Cyb-Bod-Mechanic",
	"CyborgLegs",
	"",
	11,
	"CyborgRepair"
);
Div
classnotice box ping

Be careful when creating cyborg engineers and mechanics on WZ 3.1 – see examples for how to make it work. 

Div
classbox
Availability
Status
colourYellow
title3.1 b1+

Requires:

  • Warzone 3.1 Beta 1 and above.
  • Warzone 3.2 makes cyborg engineer/mechanic production more reliable
Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

See also

How To's:

Include Page
.jslinks-droids
.jslinks-droids