Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Excerpt |
---|
Find a good location for a specific droid to build a specific structure. |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var pos = pickStructLocation(droid, structure, x, y); |
Parameters
Parameter | Type | Mandatory | Notes | Game Version |
---|---|---|---|---|
droid | Droid object | The construction droid that will do the building. Must be of type DROID_CONSTRUCT. | 3.1 Beta 1 | |
structure | String | The string ID of the type of structure you want to build. | 3.1 Beta 1 | |
x | Number | The x co-ordinate of the desired construction site. | 3.1 Beta 1 | |
y | Number | The y co-ordinate of the desired construction site. | 3.1 Beta 1 |
Return values
Value | Type | Notes | Game Version |
---|---|---|---|
<pos> | Position object | A position object specifying the '.x' and '.y' co-ordinates where the structure can be built. The '.type' property was added to the object in Warzone 3.1 RC 3. On earlier versions, the object did not have a '.type' property. | 3.1 Beta 1 Updated in 3.1 RC 3 |
<error> | Error | Invalid parameters specified, for example the droid was not of type DROID_CONSTRUCT or the structure type was not found. | 3.1 Beta 1 |
undefined | Undefined | A suitable location can not be found within range of the co-ordinates requested (x and y parameters of the function). | 3.1 Beta 1 |
Example
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
// let's build a factory var struct = "A0LightFactory"; // can we actually build a factory? if (isStructureAvailable(struct)) { // this assumes we have a truck (will throw ReferenceError if not) // you should check other things (like truck not busy, etc) too // but we'll keep it super-basic for this example... var truck = enumDroid(me, DROID_CONSTRUCT)[0]; // build it near our construction truck var pos = pickStructLocation(truck, struct, truck.x, truck.y); // check we found a location and truck can reach location if (pos && droidCanReach(truck, pos.x, pos.y)) { // get droid to build factory at location orderDroidBuild(truck, DORDER_BUILD, struct, pos.x, pos.y); } } |
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
It's possible an additional parameter will be added in future versions to define the size of the gap required around the structure. |
Div | ||||
---|---|---|---|---|
| ||||
ContentsJump to:
|
Div | ||
---|---|---|
| ||
See alsoRelated articles:
|