Other great resources: Official JS API docs, Scripting Forum
structureIdle()
Check if a structure is idle...
Syntax
var returnValue = ( (structure.status == BUILT) && structureIdle(structure) );Parameters
Parameter | Type | Mandatory | Notes | Game version |
|---|---|---|---|---|
structure | The structure to examine. See warning box top-right of this page first! | 3.1 Beta 1 |
Return values
Value | Type | Description | Game version |
|---|---|---|---|
| Boolean | Indicates the structure is idle | 3.1 Beta 1 |
| 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?
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().