Difference between revisions of "Oolite JavaScript Reference: EquipmentInfo"

From Elite Wiki
(Added Equipment Expressions section.)
(Updated for 1.74.)
Line 1: Line 1:
 
<small>'''Prototype:''' <code>Object</code></small><br />
 
<small>'''Prototype:''' <code>Object</code></small><br />
 
{{Oolite-class-added|1.72}}
 
   
 
'''<code>EquipmentInfo</code>''' objects provide information about a type of equipment. To acquire an <code>EquipmentInfo</code> object, use the <code>[[#infoForKey|infoForKey]]()</code> method, as in:
 
'''<code>EquipmentInfo</code>''' objects provide information about a type of equipment. To acquire an <code>EquipmentInfo</code> object, use the <code>[[#infoForKey|infoForKey]]()</code> method, as in:
Line 8: Line 6:
 
=== Equipment Expressions ===
 
=== Equipment Expressions ===
 
Many methods can take either an <code>EquipmentInfo</code> or an equipment key. For instance, <code>ship.hasEquipment("EQ_ECM")</code> is equivalent to <code>ship.hasEquipment(EquipmentInfo.infoForKey("EQ_ECM"))</code>. In specifications, this is represented by arguments typed <code>equipmentInfoExpression</code>.
 
Many methods can take either an <code>EquipmentInfo</code> or an equipment key. For instance, <code>ship.hasEquipment("EQ_ECM")</code> is equivalent to <code>ship.hasEquipment(EquipmentInfo.infoForKey("EQ_ECM"))</code>. In specifications, this is represented by arguments typed <code>equipmentInfoExpression</code>.
 
Prior to Oolite 1.74, such methods would only accept equipment keys.
 
   
 
== Properties ==
 
== Properties ==
Line 19: Line 15:
 
'''effectiveTechLevel''' : Number (read/write nonnegative integer)
 
'''effectiveTechLevel''' : Number (read/write nonnegative integer)
 
The effective tech level required to purchase this item. Unlike <code>[[#techLevel|techLevel]]</code>, this takes the special meaning of 99 and <code>TL_FOR_EQ_WHATEVER</code> mission variables into account. If the raw tech level is 99, changing the value of <code>[[#effectiveTechLevel|effectiveTechLevel]]</code> is equivalent to setting the appropriate <code>TL_FOR_EQ_WHATEVER</code> mission variable. If the raw tech level is not 99, changes to <code>[[#effectiveTechLevel|effectiveTechLevel]]</code> are ignored.<br>
 
The effective tech level required to purchase this item. Unlike <code>[[#techLevel|techLevel]]</code>, this takes the special meaning of 99 and <code>TL_FOR_EQ_WHATEVER</code> mission variables into account. If the raw tech level is 99, changing the value of <code>[[#effectiveTechLevel|effectiveTechLevel]]</code> is equivalent to setting the appropriate <code>TL_FOR_EQ_WHATEVER</code> mission variable. If the raw tech level is not 99, changes to <code>[[#effectiveTechLevel|effectiveTechLevel]]</code> are ignored.<br>
Starting with 1.74: Setting "effectiveTechLevel = null", will remove the corresponding <code>TL_FOR_EQ_WHATEVER</code> mission variable.
+
Setting <code>effectiveTechLevel</code> to <code>null</code>, will remove the corresponding <code>TL_FOR_EQ_WHATEVER</code> mission variable.
   
 
'''See also: <code>[[#techLevel|techLevel]]</code>
 
'''See also: <code>[[#techLevel|techLevel]]</code>
Line 102: Line 98:
   
 
=== <code>scriptInfo</code> ===
 
=== <code>scriptInfo</code> ===
{{Oolite-prop-future|1.74}}
 
 
'''scriptInfo''' : Object (read-only)
 
'''scriptInfo''' : Object (read-only)
 
The contents of the <code>script_info</code> key in the equipments’s ''[[equipment.plist]]'' entry, if any. This may be any [[property list]] object, but the reccomended approach is to use a dictionary whose keys have a unique prefix (such as you should be using for file names, ship names etc.). A property list dictionary is converted to a JavaScript object with properties corresponding to the dictionary’s keys. All other property list types used with Oolite have directly corresponding JavaScript types.
 
The contents of the <code>script_info</code> key in the equipments’s ''[[equipment.plist]]'' entry, if any. This may be any [[property list]] object, but the reccomended approach is to use a dictionary whose keys have a unique prefix (such as you should be using for file names, ship names etc.). A property list dictionary is converted to a JavaScript object with properties corresponding to the dictionary’s keys. All other property list types used with Oolite have directly corresponding JavaScript types.
Line 111: Line 106:
   
 
'''See also: <code>[[#effectiveTechLevel|effectiveTechLevel]]</code>
 
'''See also: <code>[[#effectiveTechLevel|effectiveTechLevel]]</code>
  +
  +
== Static properties ==
  +
=== <code>allEquipment</code> ===
  +
{{Oolite-prop-added|1.74}}
  +
allEquipment : Array (EquipmentInfos, read-only)
  +
Returns a list of all known equipment types.
   
 
== Static methods ==
 
== Static methods ==

Revision as of 20:29, 17 June 2010

Prototype: Object

EquipmentInfo objects provide information about a type of equipment. To acquire an EquipmentInfo object, use the infoForKey() method, as in:

var missileInfo = EquipmentInfo.infoForKey("EQ_MISSILE");

Equipment Expressions

Many methods can take either an EquipmentInfo or an equipment key. For instance, ship.hasEquipment("EQ_ECM") is equivalent to ship.hasEquipment(EquipmentInfo.infoForKey("EQ_ECM")). In specifications, this is represented by arguments typed equipmentInfoExpression.

Properties

description

description : String (read-only)

A short description of the equipment, as seen on the Ship Outfitting screen.

effectiveTechLevel

effectiveTechLevel : Number (read/write nonnegative integer)

The effective tech level required to purchase this item. Unlike techLevel, this takes the special meaning of 99 and TL_FOR_EQ_WHATEVER mission variables into account. If the raw tech level is 99, changing the value of effectiveTechLevel is equivalent to setting the appropriate TL_FOR_EQ_WHATEVER mission variable. If the raw tech level is not 99, changes to effectiveTechLevel are ignored.
Setting effectiveTechLevel to null, will remove the corresponding TL_FOR_EQ_WHATEVER mission variable.

See also: techLevel

equipmentKey

equipmentKey : String (read-only)

The equipment key for the equipment described by this EquipmentInfo object. For EQ_MISSILE, this is "EQ_MISSILE".

incompatibleEquipment

incompatibleEquipment : Array (read-only)

An array of equipment keys (in arbitrary order). In order to be installed, no item in this array may already be installed.

See also: requiresAnyEquipment, requiresEquipment

isAvailableToAll

isAvailableToAll : Boolean (read-only)

isExternalStore

isExternalStore : Boolean (read-only)

True for _MISSILE and _MINE equipment types.

isPortableBetweenShips

isPortableBetweenShips : Boolean (read-only)

name

name : String (read-only)

The display name for the equipment described by this EquipmentInfo object. This string is localized. For EQ_MISSILE in English, this is "Missile".

price

price : Number (read-only nonnegative integer)

This is the value as used in the equipment.plist. Divide this by ten for the real value in credits.

requiredCargoSpace

requiredCargoSpace : Number (read-only nonnegative integer)

requiresAnyEquipment

requiresAnyEquipment : Array (read-only)

An array of equipment keys (in arbitrary order). In order to be installed, at least one item in this array must already be installed.

See also: incompatibleEquipment, requiresEquipment

requiresCleanLegalRecord

requiresCleanLegalRecord : Boolean (read-only)

See also: requiresNonCleanLegalRecord

requiresEmptyPylon

requiresEmptyPylon : Boolean (read-only)

True for equipment that requires at least one pylon to have nothing on it.

See also: requiresMountedPylon

requiresEquipment

requiresEquipment : Array (read-only)

An array of equipment keys (in arbitrary order). In order to be installed, all items in this array must already be installed.

See also: incompatibleEquipment, requiresAnyEquipment

requiresFreePassengerBerth

requiresFreePassengerBerth : Boolean (read-only)

requiresFullFuel

requiresFullFuel : Boolean (read-only)

See also: requiresNonFullFuel

requiresMountedPylon

requiresMountedPylon : Boolean (read-only)

True for equipment that requires at least one pylon to have a store (missile, mine or equipment) on it.

See also: requiresEmptyPylon

requiresNonCleanLegalRecord

requiresNonCleanLegalRecord : Boolean (read-only)

See also: requiresCleanLegalRecord

requiresNonFullFuel

requiresNonFullFuel : Boolean (read-only)

See also: requiresFullFuel

scriptInfo

scriptInfo : Object (read-only)

The contents of the script_info key in the equipments’s equipment.plist entry, if any. This may be any property list object, but the reccomended approach is to use a dictionary whose keys have a unique prefix (such as you should be using for file names, ship names etc.). A property list dictionary is converted to a JavaScript object with properties corresponding to the dictionary’s keys. All other property list types used with Oolite have directly corresponding JavaScript types.

techLevel

techLevel : Number (read-only nonnegative integer)

The raw tech level required to purchase this item. Unlike effectiveTechLevel, this does not take the special meaning of 99 and TL_FOR_EQ_WHATEVER mission variables into account.

See also: effectiveTechLevel

Static properties

allEquipment

This property was added in Oolite test release 1.74.

allEquipment : Array (EquipmentInfos, read-only)

Returns a list of all known equipment types.

Static methods

infoForKey

function infoForKey(equipmentKey : String) : EquipmentInfo

Returns the equipment info object for a given type of equipment, or null for an unrecognised key. Example: var missileInfo = EquipmentInfo.infoForKey("EQ_MISSILE");