Difference between revisions of "Oolite JavaScript Reference: Manifest"
Eric Walch (talk | contribs) (Added info about maximum quantities) |
Eric Walch (talk | contribs) (Added info about cargo handling in flight.) |
||
Line 122: | Line 122: | ||
} |
} |
||
+ | == Additional info == |
||
+ | When a player launches, all cargo from the manifest is loaded in cargo pods with role: "1t-cargopod". This has some consequences for handling kg and gram commodities when in flight: |
||
+ | |||
+ | - Every full ton of such an article that the player has, is put in a barrel on launch and consumes 1 ton cargo space.<br> |
||
+ | - Every barrel that the player scoops takes one ton of cargo space even when the content is far less in weight.<br> |
||
+ | - Every time cargo is added by script, the added amount is added in an one ton barrel to the hold. (a barrel with role: "1t-cargopod")<br> |
||
+ | - 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.<br> |
||
+ | |||
+ | 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 above cargo handling might explain why the hold fills up fast when adding several small quantities of kg/gram commodities by script.<br> |
||
+ | Nothing new actually as the addition per container when in flight already happened this way with the legacy scripts. |
||
[[Category:Oolite scripting]] |
[[Category:Oolite scripting]] |
Revision as of 21:17, 21 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.
Contents
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); }
Additional info
When a player launches, all cargo from the manifest is loaded in cargo pods with role: "1t-cargopod". This has some consequences for handling kg and gram commodities when in flight:
- Every full ton of such an article that the player has, is put in a barrel on launch and consumes 1 ton cargo space.
- Every barrel that the player scoops takes one ton of cargo space even when the content is far less in weight.
- Every time cargo is added by script, the added amount is added in an one ton barrel to the hold. (a barrel with role: "1t-cargopod")
- 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 above cargo handling might explain why the hold fills up fast when adding several small quantities of kg/gram commodities by script.
Nothing new actually as the addition per container when in flight already happened this way with the legacy scripts.