(info) 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

ParameterTypeMandatoryNotesGame version
structureStructure object(tick)

The structure to examine.

(warning) See warning box top-right of this page first!

3.1 Beta 1

Return values

ValueTypeDescriptionGame version
trueBooleanIndicates the structure is idle3.1 Beta 1
falseBooleanIndicates the structure is busy (or does not have an "idle" state)3.1 Beta 1
<error>ErrorThe 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)