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
Build a factory, if we can...
// 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);
}
}
Availability STABLE
Requires:
Warzone 3.1 Beta 1 and above
Return value changed in Warzone 3.1 RC 3
It's possible an additional parameter will be added in future versions to define the size of the gap required around the structure.