Other great resources: Official JS API docs, Scripting Forum
structureIdle()
- Aubergine
Owned by Aubergine
Check if a structure is idle...
Syntax
var returnValue = ( (structure.status == BUILT) && structureIdle(structure) );
Parameters
Parameter | Type | Mandatory | Notes | Game version |
---|---|---|---|---|
structure | Structure object | The structure to examine. See warning box top-right of this page first! | 3.1 Beta 1 |
Return values
Value | Type | Description | Game version |
---|---|---|---|
true | Boolean | Indicates the structure is idle | 3.1 Beta 1 |
false | Boolean | Indicates the structure is busy (or does not have an "idle" state) | 3.1 Beta 1 |
<error> | Error | The structure was not found. | 3.1 Beta 1 |
Notes
This function can be used to check if a structure that produces something, or has a special ability, is idle. Supported structures include:
Factories – are they ready for their next order?
They might still appear 'idle' for a short time after giving them a new order.
- Research labs – are they ready for their next research task?
- Laser Satellite – is it ready for next attack?
You can use this function on structures owned by any player, not just your own structures.
Examples
Find idle Laser Satellites
var laserSatellites = enumStruct(me, LASSAT); // get a list of my laser satellites laserSatellites.forEach( function(satellite) { if ( (satellite.status == BUILT) && structureIdle(satellite) ) { // do stuff, eg. activateStructure() } } );
For an example of getting idle labs to research technologies, see enumResearch().
Always check that the structure is BUILT before checking to see if it is idle. Also, after telling a factory to produce something it might still appear idle for a short amount of time.
Availability 3.1 B1+
Requires:
- Warzone 3.1 Beta 1 and above
Contents
Jump to:
See also
Related articles:
- activateStructure() – instruct a structure to perform it's special action (eg. fire laser satellite)
- BUILT – indicates a structure is fully built
- pursueResearch() – research technology at a research laboratory
- buildDroid() – build a droid at a factory
- eventStructureReady() – event triggered when a structure is ready
- eventDroidBuilt() – tells you when a droid has been build, and which factory built it (factory will usually be idle)
- eventResearched() – tells you when research is complete, and which lab completed it (lab will usually be idle)