Difference between revisions of "Oolite JavaScript Reference: Manifest"

From Elite Wiki
(Added info about maximum quantities)
Line 17: Line 17:
 
Manifest["food"] += 10;
 
Manifest["food"] += 10;
   
If there were less than 10 tons of cargo space available, any extra cargo is silently discarded.
+
If there were less than 10 tons of cargo space available, any extra cargo is silently discarded. A script should therefor first check the [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpaceAvailable]].
   
 
=== <code>textiles</code> ===
 
=== <code>textiles</code> ===
Line 69: Line 69:
 
=== <code>gold</code> ===
 
=== <code>gold</code> ===
 
'''gold''' : Integer (read/write)
 
'''gold''' : Integer (read/write)
Quantity of gold in the players ship.
 
  +
Quantity of gold in the players ship. 500 kg and more counts as 1 ton, below 500 kg counts as 0 ton in [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpace]] calculations. Therefor a script can only add up to 499 kg of gold into a filled hold. (The player himself can buy unlimited quantities at the market screen.)
   
 
=== <code>platinum</code> ===
 
=== <code>platinum</code> ===
 
'''platinum''' : Integer (read/write)
 
'''platinum''' : Integer (read/write)
Quantity of platinum in the players ship.
+
Quantity of platinum in the players ship. 500 kg and more counts as 1 ton in [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpace]] calculations.
   
 
=== <code>"gem-stones"</code> ===
 
=== <code>"gem-stones"</code> ===
 
'''gem-stones''' (or '''gemStones'''): Integer (read/write)
 
'''gem-stones''' (or '''gemStones'''): Integer (read/write)
Quantity of gem-stones in the players ship.<br>
+
Quantity of gem-stones in the players ship. 500000 g and more counts as 1 ton in [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpace]] calculations.<br>
 
Access to the '''gem-stones''' property is via
 
Access to the '''gem-stones''' property is via
 
Manifest["gem-stones"]
 
Manifest["gem-stones"]

Revision as of 09:36, 5 May 2010

Prototype: Object

This class was added in Oolite test release 1.74.

Manifest provides direct access to the cargo carried by the player.

Properties

food

food : Integer (read/write)

Quantity of food in the players ship.

Awarding the player with extra 10 tons of food can be done in different ways:

Manifest.food += 10;
or
player.ship.manifest.food += 10;
or
Manifest["food"] += 10;

If there were less than 10 tons of cargo space available, any extra cargo is silently discarded. A script should therefor first check the cargoSpaceAvailable.

textiles

textiles : Integer (read/write)

Quantity of textiles in the players ship.

radioactives

radioactives : Integer (read/write)

Quantity of radioactives in the players ship.

slaves

slaves : Integer (read/write)

Quantity of slaves in the players ship.

"liquor/wines"

liquor/wines (or liquorWines): Integer (read/write)

Quantity of liquor/wines in the players ship.
Access the liquor/wines quantity on the hold via either

Manifest["liquor/wines"]
or
Manifest.liquorWines

luxuries

luxuries : Integer (read/write)

Quantity of luxuries in the players ship.

narcotics

narcotics : Integer (read/write)

Quantity of narcotics in the players ship.

computers

computers : Integer (read/write)

Quantity of computers in the players ship.

alloys

alloys : Integer (read/write)

Quantity of alloys in the players ship.

firearms

firearms : Integer (read/write)

Quantity of firearms in the players ship.

furs

furs : Integer (read/write)

Quantity of furs in the players ship.

minerals

minerals : Integer (read/write)

Quantity of minerals in the players ship.

gold

gold : Integer (read/write)

Quantity of gold in the players ship. 500 kg and more counts as 1 ton, below 500 kg counts as 0 ton in cargoSpace calculations. Therefor a script can only add up to 499 kg of gold into a filled hold. (The player himself can buy unlimited quantities at the market screen.)

platinum

platinum : Integer (read/write)

Quantity of platinum in the players ship. 500 kg and more counts as 1 ton in cargoSpace calculations.

"gem-stones"

gem-stones (or gemStones): Integer (read/write)

Quantity of gem-stones in the players ship. 500000 g and more counts as 1 ton in cargoSpace calculations.
Access to the gem-stones property is via

Manifest["gem-stones"]
or
Manifest.gemStones

"alien items"

alien items (alternative name alienItems): Integer (read/write)

Quantity of alien items in the players ship.
Access the alien items property either via

Manifest["alien items"]
or
Manifest.alienItems

list

list : Array (read-only)

Array of objects. Each object contains the info for a commodity present in the player's hold:

commodity : String (corresponds to manifest["commodity"])
quantity : Integer
displayName : String (commodity display name, can be different for different languages)
unit : String ('t' = tons, 'kg' = kilograms, 'g' = grams)

Example usages of the manifest.list property

var i, m;

// for certain types of cargo (like gem-stones) player.ship.cargoSpaceUsed can still be 0
// even if we're carrying 100 or more.
log('The player is currently carrying ' + (manifest.list.length > 0 ?'the following:' : 'nothing.'))

for (i = 0; i<manifest.list.length;i++)
{
  m = manifest.list[i];
  log( m.quantity + m.unit + ' of '+ m.displayName );
}

and

var i, c;

// now remove at least 1 of / 20% of each type of cargo carried.
for (i = 0; i<manifest.list.length;i++)
{
	c = manifest.list[i].commodity;
	manifest[c] = Math.floor(manifest[c] * .8);
}