Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Excerpt

Quickly determine if a structure of the specified type has been fully built.

Availability

...

 

Code

Code Block
theme

...

RDark
languagejavascript
linenumberstrue
// iHave(structureTypeOrID) returns true if you have
// at least one of those structures fully built
var iHave = (function(){
  var buildingIsBuilt = function(building) {
    return building.status == BUILT;
  }
  return function (structure) {
    return enumStruct(me,structure).some(buildingIsBuilt);
  }
})();

Example

Code Block
theme

...

RDark
languagejavascript
linenumberstrue
// You need a HQ before you can design units or build defence towers
if (iHave(HQ)) {
  // build defence towers
} else {
  // instruct a truck to build a HQ!
}
Div
classbox

Availability

Requires:

  • Warzone 3.1 Beta 1 and above.
Div
classbox

See also

Relates articles:

  • enumStruct() – get a list of structures
  • BUILT – indicates structure is fully built
  • HQ – headquarters (Command Control) structure type
  • me – my player ID
  • .status – the construction status of a structure object
  • .stattype – constants defining structure types
  • Structure object – defines a structure object