Other great resources: Official JS API docs, Scripting Forum
componentAvailable()
Check if a droid component is available...
Syntax
// Warzone 3.1.0 and earlier
componentAvailable(type, name)
// Warzone 3.2 and later: the type param is deprecated
componentAvailable([type,] name)Parameters
Parameter | Type | Mandatory | Notes | Game version |
|---|---|---|---|---|
type | Constant | The type of component. This parameter is optional in Warzone 3.2 and above. These constants are not exposed to JS API (#3898) – see "Notes" section below for details. | 3.1 Beta 1 Deprecated in 3.2 | |
name | String | The component name. Example: | 3.1 Beta 1 |
Return value
Value | Type | Notes | Game version |
|---|---|---|---|
| Boolean | The component is available for use. | 3.1 Beta 1 |
| Boolean | The component is not currently available. | 3.1 Beta 1 |
<error> | Error | Invalid parameters. | 3.1 Beta 1 |
Notes
Currently, the component type constants aren't exposed to JS API (as of WZ 3.1.0 release). As such, you need to define them manually:
Constant | Value | Notes |
|---|---|---|
| 0 | Not currently used as far as I can tell |
| 1 | Bodies |
| 2 | Command turrets |
| 3 | Propulsions |
| 4 | Repair turrets |
| 5 | ECM turrets |
| 6 | Sensor / Radar turrets |
| 7 | Construction turrets |
| 8 | Weapon turrets |
Example
const COMP_PROPULSION = 3;
if (componentAvailable(COMP_PROPULSION, "hover01")) {
// we can build hovercraft!
}