Difference between revisions of "Oolite JavaScript Reference: Manifest"
m (Moving Oolite JS reference into a *correctly-named* subcategory of Oolite scripting.) |
(Undocumenting plusungood unrec nonforms p.p. MINITRUE) |
||
Line 47: | Line 47: | ||
The quantity of slaves in the ship’s hold (t). |
The quantity of slaves in the ship’s hold (t). |
||
− | === <code> |
+ | === <code>liquorWines</code> === |
− | + | '''liquorWines''' : Number (read/write integer) |
|
The quantity of liquor/wines in the ship’s hold (t). |
The quantity of liquor/wines in the ship’s hold (t). |
||
− | |||
− | Access the '''liquor/wines''' quantity on the hold as either <code>player.ship.manifest["liquor/wines"]</code> or <code>player.ship.manifest.liquorWines</code>. |
||
=== <code>luxuries</code> === |
=== <code>luxuries</code> === |
||
Line 89: | Line 87: | ||
The quantity of platinum in the ship’s hold (kg). |
The quantity of platinum in the ship’s hold (kg). |
||
− | === <code> |
+ | === <code>gemStones</code> === |
− | + | '''gemStones''' : Number (read/write integer) |
|
− | The quantity of gem-stones in the ship’s hold. 500000 g and more counts as 1 ton in [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpace]] calculations. |
+ | The quantity of gem-stones in the ship’s hold. 500000 g and more counts as 1 ton in [[Oolite JavaScript Reference: Ship#cargoSpaceAvailable|cargoSpace]] calculations. |
− | Access to the '''gem-stones''' property is via |
||
− | Manifest["gem-stones"] |
||
− | or |
||
− | Manifest.gemStones |
||
− | === <code> |
+ | === <code>alienItems</code> === |
− | + | '''alienItems''' : Number (read/write integer) |
|
The quantity of alien items in the ship’s hold. |
The quantity of alien items in the ship’s hold. |
||
− | |||
− | Access the '''alien items''' quantity on the hold as either <code>player.ship.manifest["alien items"]</code> or <code>player.ship.manifest.alienItems</code>. |
||
=== <code>list</code> === |
=== <code>list</code> === |
Revision as of 20:40, 19 June 2010
Prototype: Object
Subtypes: none
This class was added in Oolite test release 1.74.
Manifest
provides direct access to the cargo carried by the player.
Except list
, each property is an integer representing the quantity of a certain commodity. The units depend on the commodity, just as on the trading screen.
Contents
Behaviour notes
When increasing a commodity, extra cargo beyond the ship’s capacity is discarded silently. For example, if the ship has 6 t of space available, and you add 10 to player.ship.manifest.food
, only 6 t of food will be awarded.
For gold an platinum, 500 kg and more rounds up to 1 t, below 500 kg counts as 0 t in cargo space calculations. This means as script can add up to 499 kg of gold or platinum into a nominally full hold. (The player himself can buy unlimited quantities at the market screen.) In the same way, 500 000 g of gemstones is rounded up to 1 t. (If you feel tempted to award the player half a tonne of gemstones, keep in mind that one can only sell up to 127 units of a commodity at a given station using the trading screen.)
Example:
if (player.ship.cargoSpaceAvailable >= 10) { player.ship.manifest.food += 10; }
Cargo marshalling
When a player launches, all cargo from the manifest is loaded in cargo pods with the role “1t-cargopod”. This has some consequences for handling g and kg commodities when in flight:
- Every full t of such an article that the player has is put in a barrel on launch and consumes 1 t cargo space.
- Every barrel that the player scoops takes one t of cargo space even when the content is far less in weight.
- Every time cargo is added by script, the added amount is added to the hold in one or more 1 t cargo pods.
- Every time the cargo is reduced, it is removed from one of the barrels. When the barrel becomes empty in the process, the barrel is removed.
On docking all barrels are unloaded and the manifest becomes just a list of goods. The manifest can be handled the same way when docked as when in flight, but the behaviour described above explains why the hold fills up fast when adding several small quantities of g/kg commodities by script.
Properties
food
food : Number (read/write integer)
The quantity of food in the ship’s hold (t).
textiles
textiles : Number (read/write integer)
The quantity of textiles in the ship’s hold (t).
radioactives
radioactives : Number (read/write integer)
The quantity of radioactives in the ship’s hold (t).
slaves
slaves : Number (read/write integer)
The quantity of slaves in the ship’s hold (t).
liquorWines
liquorWines : Number (read/write integer)
The quantity of liquor/wines in the ship’s hold (t).
luxuries
luxuries : Number (read/write integer)
The quantity of luxuries in the ship’s hold (t).
narcotics
narcotics : Number (read/write integer)
The quantity of narcotics in the ship’s hold (t).
computers
computers : Number (read/write integer)
The quantity of computers in the ship’s hold (t).
alloys
alloys : Number (read/write integer)
The quantity of alloys in the ship’s hold (t).
firearms
firearms : Number (read/write integer)
The quantity of firearms in the ship’s hold (t).
furs
furs : Number (read/write integer)
The quantity of furs in the ship’s hold (t).
minerals
minerals : Number (read/write integer)
The quantity of minerals in the ship’s hold (t).
gold
gold : Number (read/write integer)
The quantity of gold in the ship’s hold (kg).
platinum
platinum : Number (read/write integer)
The quantity of platinum in the ship’s hold (kg).
gemStones
gemStones : Number (read/write integer)
The quantity of gem-stones in the ship’s hold. 500000 g and more counts as 1 ton in cargoSpace calculations.
alienItems
alienItems : Number (read/write integer)
The quantity of alien items in the ship’s hold.
list
list : Array (read-only)
Array of objects. Each object contains information for a commodity present in the player’s hold:
commodity : String (the name of the corresponding property) quantity : Number (integer) displayName : String (commodity display name, can be different for different languages) unit : String (“t”, “kg” or “g”)
Examples:
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] * 0.8); }