Difference between revisions of "Ship Storage Helper"

From Elite Wiki
m
(Updating BB links)
 
(29 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Use at least the [http://wiki.alioth.net/index.php?title=Ship_Storage_Helper#Download 0.21 version] to avoid memory problems if many OXP ships installed
+
Allows "storing" one's ship to replace it with another. Mostly used by other OXPs.
 
 
== Ship_Storage_Helper.oxp==
 
 
 
Capt Murphy 2012
 
Licence: CC BY-NC-SA 3.0 - see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
 
Requires: Oolite 1.77 - Trunk builds after revision 5025 (nightly build 23/06/12).
 
Version 0.20 24/06/12
 
 
 
==Overviev==
 
  
 +
==Overview==
 
Ship_Storage_Helper contains helper functions for OXP writers that wish to use the new Trunk JS method player.replaceShip(dataKey[,entityPerosnality]). It facilitates storing information about the current player ship in a variable or missionVariable, and reinstating a stored player ship as the players current ship, taking into account known OXP variables that also need to be stored/reinstated.
 
Ship_Storage_Helper contains helper functions for OXP writers that wish to use the new Trunk JS method player.replaceShip(dataKey[,entityPerosnality]). It facilitates storing information about the current player ship in a variable or missionVariable, and reinstating a stored player ship as the players current ship, taking into account known OXP variables that also need to be stored/reinstated.
  
Line 19: Line 11:
  
 
New Cargoes, HyperCargo, Vortex, APRIL, Iron Hide, Missiles and Bombs, Railgun, Target Autolock Plus, Target Reticle Sensitive, Armoury, Aquatics, Battle Damage, 'Breakables', TCAT, Respray for Griffs.
 
New Cargoes, HyperCargo, Vortex, APRIL, Iron Hide, Missiles and Bombs, Railgun, Target Autolock Plus, Target Reticle Sensitive, Armoury, Aquatics, Battle Damage, 'Breakables', TCAT, Respray for Griffs.
 +
 +
== License ==
 +
*Author: [[User:Capt. Murphy|Capt. Murphy]]
 +
*Licence: CC BY-NC-SA 3.0 - see http://creativecommons.org/licenses/by-nc-sa/3.0/ for more info.
 +
*Requires: Oolite 1.77 - Trunk builds after revision 5025 (nightly build 23/06/12).
  
 
== Functions ==
 
== Functions ==
  
worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
+
  var myShipData = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
  
 
This function can be called from other worldScripts immediately before changing the player's ship with player.replaceShip(dataKey), and returns a string including the stored ships essential attributes.
 
This function can be called from other worldScripts immediately before changing the player's ship with player.replaceShip(dataKey), and returns a string including the stored ships essential attributes.
  
worldScripts["Ship_Storage_Helper.js"].restoreStoredShip(storedShipString)
+
  worldScripts["Ship_Storage_Helper.js"].restoreStoredShip(storedShipString)
  
 
This function takes the output of storeCurrentShip as an argument and uses it to reinstate the player ship from the stored information. Returns true if successful or one of the following error strings if it fails.
 
This function takes the output of storeCurrentShip as an argument and uses it to reinstate the player ship from the stored information. Returns true if successful or one of the following error strings if it fails.
  
"Error-Invalid Parameter, expected String" - indicates that storedShipString is in wrong format
+
  "Error-Invalid Parameter, expected String" - indicates that storedShipString is in wrong format
"Error-Invalid Parameter, array incorrect length" - indicates that storedShipString was created by a newer version of Ship_Storage_Helper.
+
  "Error-Invalid Parameter, array incorrect length" - indicates that storedShipString was created by a newer version of Ship_Storage_Helper.
"Error-Invalid dataKey" - indicates that the OXP that defined that dataKey has been removed since storedShipString was created.
+
  "Error-Invalid dataKey" - indicates that the OXP that defined that dataKey has been removed since storedShipString was created.
  
 
The output of storeCurrentShip is a JSON stringified array of ship attributes, containing the following indices as of v0.16.
 
The output of storeCurrentShip is a JSON stringified array of ship attributes, containing the following indices as of v0.16.
  
  0: Place and time of storage - Array [galaxyNumber,system.ID,clock.seconds,player.ship.displayName,system.name,stationAttributes,player.ship.price] (stationAttributes are [player.ship.dockedStation.primaryRole, player.ship.dockedStation.dataKey, player.ship.dockedStation.position])
+
  0: Place and time of storage - Array
 +
    [galaxyNumber,system.ID,clock.seconds,ship.displayName,system.name,stationAttributes,ship.price
 +
ship.shipClassName, ship.shipUniqueName, ship.AIScriptWakeTime, ship.beaconLabel,
 +
ship.destinationSystem, ship.exhaustEmissiveColor, ship.homeSystem,
 +
ship.maxYaw, ship.maxPitch, ship.maxRoll, ship.maxThrust, ship.thrust,
 +
ship.maxSpeed, ship.maxEnergy, ship.energyRechargeRate, ship.cargoSpaceCapacity,
 +
ship.injectorBurnRate, ship.injectorSpeedFactor, ship.scanDescription, ship.hyperspaceSpinTime,
 +
ship.scannerHostileDisplayColor1, ship.scannerHostileDisplayColor2,
 +
ship.forwardShield, ship.maxForwardShield, ship.forwardShieldRechargeRate,
 +
ship.aftShield, ship.maxAftShield, ship.aftShieldRechargeRate,
 +
ship.passengerCapacity]
 +
    (stationAttributes are [player.ship.dockedStation.primaryRole,  
 +
    player.ship.dockedStation.dataKey, player.ship.dockedStation.position])
 
  1: dataKey (e.g. "cobra3-player")
 
  1: dataKey (e.g. "cobra3-player")
 
  2: aftWeapon equipmentKey
 
  2: aftWeapon equipmentKey
Line 44: Line 53:
 
  6: Array of pylon equipmentKeys
 
  6: Array of pylon equipmentKeys
 
  7: Array of normal equipment equipmentKeys & equipmentStatus
 
  7: Array of normal equipment equipmentKeys & equipmentStatus
  8: Array of manifest contents.
+
  8: (v0.37 and prior) Array of manifest contents (v0.38) Dictionary of commodity names with quantities (eg {"food":2, "gold":5})
 
  9: fuel
 
  9: fuel
 
  10: passenger contracts
 
  10: passenger contracts
  11: array of subEnts (only if frangible subEnts are missing on storage)
+
  11: array of subEnts (only if frangible subEnts are missing on storage) with subEntityRotation.
 
  12: serviceLevel
 
  12: serviceLevel
 
  13: entityPersonality
 
  13: entityPersonality
  14: unused
+
  14: Array of ship sizes, mass and usability for Norby's EscortDeck
 
  15: Cim's New Cargoes suspended cargo variable
 
  15: Cim's New Cargoes suspended cargo variable
 
  16: Array of Thargoid's HyperCargo missionVariables
 
  16: Array of Thargoid's HyperCargo missionVariables
Line 64: Line 73:
 
  26: Smivs Battle Damage missionVariable.
 
  26: Smivs Battle Damage missionVariable.
 
  27: Respray for Griff's missionVariables.
 
  27: Respray for Griff's missionVariables.
 +
28: Shield Cycler object.
 +
29: Laser Mount Switching System storage.
 +
30: Ship Configuration armour settings.
 +
31: Smugglers smuggling compartment cargo.
 +
32: Smugglers smuggling compartment settings.
 +
33: Breakable Lasers info
 +
34: Thargoids RepairBots missionVariable.
  
 
Individual elements can be accessed from your own script. For example-
 
Individual elements can be accessed from your own script. For example-
  
var myStoredShip = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
+
  var myStoredShip = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
var dataKey = JSON.parse(myStoredShip[1])
+
  var dataKey = JSON.parse(myStoredShip[1])
  
worldScripts["Ship_Storage_Helper.js"].disableVortexPBNSFunc(context)
+
  worldScripts["Ship_Storage_Helper.js"].disableVortexPBNSFunc(context)
worldScripts["Ship_Storage_Helper.js"].disableMaelstromPBNSFunc(context)
+
  worldScripts["Ship_Storage_Helper.js"].disableMaelstromPBNSFunc(context)
  
 
Context must be a string – valid values are “delete” & “retainName”.
 
Context must be a string – valid values are “delete” & “retainName”.
Line 77: Line 93:
 
Used to temporarily modify the behaviour of the playerBoughtNewShip function in Thargoid's Vortex.oxp, to either prevent it running, or to prevent it renaming a Vortex or Maelstrom that has previously been stored.
 
Used to temporarily modify the behaviour of the playerBoughtNewShip function in Thargoid's Vortex.oxp, to either prevent it running, or to prevent it renaming a Vortex or Maelstrom that has previously been stored.
  
worldScripts["Ship_Storage_Helper.js"].enableVortexPBNSFunc()
+
  worldScripts["Ship_Storage_Helper.js"].enableVortexPBNSFunc()
worldScripts["Ship_Storage_Helper.js"].enableMaelstromPBNSFunc()
+
  worldScripts["Ship_Storage_Helper.js"].enableMaelstromPBNSFunc()
  
 
Reverses the changes made by the above functions.
 
Reverses the changes made by the above functions.
  
worldScripts["Ship_Storage_Helper.js"].disableTCATPBNSFunc()
+
  worldScripts["Ship_Storage_Helper.js"].disableTCATPBNSFunc()
worldScripts["Ship_Storage_Helper.js"].enableTCATPBNSFunc()
+
  worldScripts["Ship_Storage_Helper.js"].enableTCATPBNSFunc()
  
 
Used to temporarily disable the playerBoughtNewShip function in Thargoid's TCAT.oxp. Buying a new ship is a trigger for mission failure in this OXP, but this may not always be appropriate behaviour using the new methods.
 
Used to temporarily disable the playerBoughtNewShip function in Thargoid's TCAT.oxp. Buying a new ship is a trigger for mission failure in this OXP, but this may not always be appropriate behaviour using the new methods.
Line 91: Line 107:
 
== Variables ==
 
== Variables ==
  
worldScripts["Ship_Storage_Helper.js"].dataKeyArray
+
  worldScripts["Ship_Storage_Helper.js"].dataKeyArray
  
 
This is an array of valid player ship dataKeys from the users currently installed OXPs. It is built at startUp. It is not necessarily comprehensive, and is less likely to be comprehensive the more unique player-flyable ships are installed. It can generally capture up to 60 to 70 unique dataKeys.
 
This is an array of valid player ship dataKeys from the users currently installed OXPs. It is built at startUp. It is not necessarily comprehensive, and is less likely to be comprehensive the more unique player-flyable ships are installed. It can generally capture up to 60 to 70 unique dataKeys.
  
 +
== Download ==
 +
[[Media:Ship_Storage_Helper_0.38.oxz|Ship_Storage_Helper_0.38.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.38.oxz}} times).
  
 +
[[Media:Ship_Storage_Helper_0.37.oxz|Ship_Storage_Helper_0.37.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.37.oxz}} times).
  
== Download ==
+
[[Media:Ship_Storage_Helper_0.36.oxz|Ship_Storage_Helper_0.36.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.36.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.35.oxz|Ship_Storage_Helper_0.35.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.35.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.34.oxz|Ship_Storage_Helper_0.34.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.34.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.33.oxz|Ship_Storage_Helper_0.33.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.33.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.32.oxz|Ship_Storage_Helper_0.32.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.32.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.31.oxz|Ship_Storage_Helper_0.31.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.31.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.30.oxz|Ship_Storage_Helper_0.30.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.30.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.29.oxz|Ship_Storage_Helper_0.29.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.29.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.28.oxz|Ship_Storage_Helper_0.28.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.28.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.27.oxz|Ship_Storage_Helper_0.27.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.27.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.26.oxz|Ship_Storage_Helper_0.26.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.26.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.25.oxz|Ship_Storage_Helper_0.25.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.25.oxz}} times).
 +
 
 +
[[Media:Ship_Storage_Helper_0.24.oxz|Ship_Storage_Helper_0.24.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.24.oxz}} times).
  
 +
[[Media:Ship_Storage_Helper_0.23.oxz|Ship_Storage_Helper_0.23.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.23.oxz}} times).
  
 
[[Media:Ship_Storage_Helper_0.22.oxz|Ship_Storage_Helper_0.22.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.22.oxz}} times).
 
[[Media:Ship_Storage_Helper_0.22.oxz|Ship_Storage_Helper_0.22.oxz]] (downloaded {{#downloads:Ship_Storage_Helper_0.22.oxz}} times).
Line 106: Line 150:
 
[https://app.box.com/s/da89bweycsiogy52mmwj Ship_Storage_Helper_0.21_2013.12.16.oxp.zip] for Oolite 1.77.
 
[https://app.box.com/s/da89bweycsiogy52mmwj Ship_Storage_Helper_0.21_2013.12.16.oxp.zip] for Oolite 1.77.
  
 +
== ChangeLog ==
 +
v0.38 31/05/22 - Fixed storage of ShieldCycler data. Fixed storage of non-core commodities. Damaged equipment now set in final passes. Added last chance attempt on adding equipment. Ensure player credit balance is the same after replacing ship.
 +
 +
v0.37 23/05/20 - Added support for Thargoids Repair Bots, and Breakable Lasers. Corrected issue with setting cargoSpaceCapacity too early (before cargo-space-adjusting equipment is installed). Fix for storing/restoring cargo from NPC ships, as well as the player ship. (Thanks to dybal for these bug fixes). Converted RTF file to text format.
 +
 +
v0.36 15/07/19 - Added a check for equipment already installed if installation function fails. Improved integration with Ship Configuration, reducing the chance of script timeouts.
 +
 +
v0.35 21/10/18 - Added a try/catch block to the missile selection routine, as it was still, occasionally, hitting the bug. Added support for Smugglers – The Galactic Underworld OXP.
 +
 +
v0.34 25/08/18 - Included a check for player bounty in case an equipment item has the “requires_clean” property set. Also tweaked the techLevel check to limit the looping, as well as reordered the sequence of checks to do the smaller loops first.
 +
 +
v0.33 22/08/18 - Attempt to fix issue with equipment conditions preventing items being added to the ship. Plus improved compatibility with UBER lasers in New Lasers OXP.
 +
 +
v0.32 09/06/18 - Fixed issue restoring ship.
  
 +
v0.31 06/06/18 - Added Ship Configuration armour settings to the array.
  
== ChangeLog ==
+
v0.30 22/03/18 - Fixed issue with Ship Configuration Armour auto-repairing damaged equipment.
 +
 
 +
v0.29 31/12/17 – Fixed the restore of UBER lasers in new lasers, thanks to fraterchaos and phkb.
 +
 
 +
v0.28‭ ‬12/10/15‭ – ‬Removed beaconLabel restore due to read-only for player.
 +
 
 +
v0.27‭ 13‬/08/15‭ – Fixed a bug in ‬cargoSpaceCapacity handling‭.
 +
 
 +
v0.26‭ ‬06/08/15‭ – Added support for LMSS OXP. Fixed ‬liquor_wines, gem_stones, alien_items and ‭multiple passenger berths.
 +
 
 +
v0.25 01/08/15 - Save the new writable ship properties in Oolite 1.82. Use the new store function of [[Shield Cycler]].
 +
 
 +
v0.24 13/04/15 - Fixed equipment restore if a required equipment comes later in the list. Fixed Shield Cycler cashback at ship restore.
 +
 
 +
v0.23‭ 10‬/01/15‭ ‬– Fixed equipment restore if the container OXP of an equipment is not exists anymore.
  
 
v0.22‭ 29‬/12/14‭ ‬– Use storedShipArray[14] for [[Carriers]] OXP and [[EscortDeck]] OXP by Norby and possible to handle NPC ships by calling storeCurrentShip‭(‬ship) and restoreStoredShip(storedShipString, ship‭).
 
v0.22‭ 29‬/12/14‭ ‬– Use storedShipArray[14] for [[Carriers]] OXP and [[EscortDeck]] OXP by Norby and possible to handle NPC ships by calling storeCurrentShip‭(‬ship) and restoreStoredShip(storedShipString, ship‭).
Line 114: Line 187:
 
v0.21 16/12/13 - Use [http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#keysForRole keysForRole] in Oolite 1.79 and a slightly improved buildDataKeyArray function in 1.77 (from [[Gallery]] OXP) to avoid memory problems if many OXP ships installed in machines with 4GB or less RAM.
 
v0.21 16/12/13 - Use [http://wiki.alioth.net/index.php/Oolite_JavaScript_Reference:_Ship#keysForRole keysForRole] in Oolite 1.79 and a slightly improved buildDataKeyArray function in 1.77 (from [[Gallery]] OXP) to avoid memory problems if many OXP ships installed in machines with 4GB or less RAM.
  
v0.16 31/5/12 – Added additional information to header including system.name as a string, information about the station the ship is stored at, and the full price of the stored ship. Added entityPersonality as a ship attribute that is saved and can be restored (maintains paint colours on Griff's ships under full shaders). Thanks to cim for making this option available from trunk revision 4968. Fixed a bug were version 0.15 was unintentionally dependent on the Breakables OXPs.
+
Note: Use at least the [http://wiki.alioth.net/index.php?title=Ship_Storage_Helper#Download 0.21 version] to avoid memory problems if many OXP ships are installed.
  
v0.17 05/06/12 - v.017 05/6/12 – Fixed a bug in handling of subEntities when the ship doesn’t have any.
+
v0.20 24/06/12 – Updated compatibility for v0.4 of Respray for Griff’s.oxp so that adjusted decals are correctly restored. Ensure that player shield strength is set to maximum on restore (thanks cim for the report).
 
 
v0.18 09/06/12 – Added compatibility for v0.2 of Respray for Griff's.oxp
 
  
 
v0.19 16/06/12 – Updated compatibility for v0.3 of Respray for Griff's.oxp
 
v0.19 16/06/12 – Updated compatibility for v0.3 of Respray for Griff's.oxp
  
v0.20 24/06/12 – Updated compatibility for v0.4 of Respray for Griff’s.oxp so that adjusted decals are correctly restored. Ensure that player shield strength is set to maximum on restore (thanks cim for the report).
+
v0.18 09/06/12 – Added compatibility for v0.2 of Respray for Griff's.oxp
  
 +
v0.17 05/06/12 - v.017 05/6/12 – Fixed a bug in handling of subEntities when the ship doesn’t have any.
  
 +
v0.16 31/5/12 – Added additional information to header including system.name as a string, information about the station the ship is stored at, and the full price of the stored ship. Added entityPersonality as a ship attribute that is saved and can be restored (maintains paint colours on Griff's ships under full shaders). Thanks to cim for making this option available from trunk revision 4968. Fixed a bug were version 0.15 was unintentionally dependent on the Breakables OXPs.
  
== Forum ==
+
== Links ==
 +
*See the Forum: [https://bb.oolite.space/viewtopic.php?f=4&t=11892 this topic].
 +
*[[Extended Shipyards]] - uses this OXP to allow rental of - or trying out - new ships
  
See [http://www.aegidian.org/bb/viewtopic.php?f=4&t=11892 this topic].
+
*[https://bb.oolite.space/viewtopic.php?f=6&t=3468 Renting a Station Hangar & Asteroid Belt Detection Equip] (2007)
  
  
 +
:''Not to be confused with''
 +
*[[HyperCargo OXP]] magical storage enhancer (on-board ship)
 +
*[[Equipment Storage OXP]] for storing equipment and cargo
  
 
[[Category:Oolite expansion packs]]
 
[[Category:Oolite expansion packs]]

Latest revision as of 03:25, 29 February 2024

Allows "storing" one's ship to replace it with another. Mostly used by other OXPs.

Overview

Ship_Storage_Helper contains helper functions for OXP writers that wish to use the new Trunk JS method player.replaceShip(dataKey[,entityPerosnality]). It facilitates storing information about the current player ship in a variable or missionVariable, and reinstating a stored player ship as the players current ship, taking into account known OXP variables that also need to be stored/reinstated.

As development and testing is ongoing it is anticipated that additional OXP compatibility code will need to included. I would be grateful if testers and OXP authors could alert me to any bugs using the current release. In the long term I hope this OXP to become a community maintained OXP as it will require regular updating in light of new OXP releases.

Current OXP Compatibility

Ship_Storage_Helper contains code to explicitly overcome compatibility issues for the following OXPs:

New Cargoes, HyperCargo, Vortex, APRIL, Iron Hide, Missiles and Bombs, Railgun, Target Autolock Plus, Target Reticle Sensitive, Armoury, Aquatics, Battle Damage, 'Breakables', TCAT, Respray for Griffs.

License

Functions

 var myShipData = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()

This function can be called from other worldScripts immediately before changing the player's ship with player.replaceShip(dataKey), and returns a string including the stored ships essential attributes.

 worldScripts["Ship_Storage_Helper.js"].restoreStoredShip(storedShipString)

This function takes the output of storeCurrentShip as an argument and uses it to reinstate the player ship from the stored information. Returns true if successful or one of the following error strings if it fails.

 "Error-Invalid Parameter, expected String" - indicates that storedShipString is in wrong format
 "Error-Invalid Parameter, array incorrect length" - indicates that storedShipString was created by a newer version of Ship_Storage_Helper.
 "Error-Invalid dataKey" - indicates that the OXP that defined that dataKey has been removed since storedShipString was created.

The output of storeCurrentShip is a JSON stringified array of ship attributes, containing the following indices as of v0.16.

0: Place and time of storage - Array
   [galaxyNumber,system.ID,clock.seconds,ship.displayName,system.name,stationAttributes,ship.price
	ship.shipClassName, ship.shipUniqueName, ship.AIScriptWakeTime, ship.beaconLabel,
	ship.destinationSystem, ship.exhaustEmissiveColor, ship.homeSystem,
	ship.maxYaw, ship.maxPitch, ship.maxRoll, ship.maxThrust, ship.thrust,
	ship.maxSpeed, ship.maxEnergy, ship.energyRechargeRate, ship.cargoSpaceCapacity,
	ship.injectorBurnRate, ship.injectorSpeedFactor, ship.scanDescription, ship.hyperspaceSpinTime, 
	ship.scannerHostileDisplayColor1, ship.scannerHostileDisplayColor2,
	ship.forwardShield, ship.maxForwardShield, ship.forwardShieldRechargeRate,
	ship.aftShield, ship.maxAftShield, ship.aftShieldRechargeRate,
	ship.passengerCapacity]
   (stationAttributes are [player.ship.dockedStation.primaryRole, 
    player.ship.dockedStation.dataKey, player.ship.dockedStation.position])
1: dataKey (e.g. "cobra3-player")
2: aftWeapon equipmentKey
3: forwardWeapon equipmentKey
4: portWeapon equipmentKey
5: starboardWeapon equipmentKey
6: Array of pylon equipmentKeys
7: Array of normal equipment equipmentKeys & equipmentStatus
8: (v0.37 and prior) Array of manifest contents (v0.38) Dictionary of commodity names with quantities (eg {"food":2, "gold":5})
9: fuel
10: passenger contracts
11: array of subEnts (only if frangible subEnts are missing on storage) with subEntityRotation.
12: serviceLevel
13: entityPersonality
14: Array of ship sizes, mass and usability for Norby's EscortDeck
15: Cim's New Cargoes suspended cargo variable
16: Array of Thargoid's HyperCargo missionVariables
17: Array of Thargoid's Vortex/Maelstrom missionVariables
18: Array of Thargoid's APRIL missionVariables
19: Array of Thargoid's IronHide missionVariables
20: Ramirez's Missile & Bombs missionVariable
21: Array of McClane's Railgun missionVariables.
22: Thargoid's TargetAutoLock Plus missionVariable.
23: Eric's TargetReticle Sensitive missionVariable.
24: Thargoid's Armoury missionVariable.
25: Thargoid's Aquatics missionVariable.
26: Smivs Battle Damage missionVariable.
27: Respray for Griff's missionVariables.
28: Shield Cycler object.
29: Laser Mount Switching System storage.
30: Ship Configuration armour settings.
31: Smugglers smuggling compartment cargo.
32: Smugglers smuggling compartment settings.
33: Breakable Lasers info
34: Thargoids RepairBots missionVariable.

Individual elements can be accessed from your own script. For example-

 var myStoredShip = worldScripts["Ship_Storage_Helper.js"].storeCurrentShip()
 var dataKey = JSON.parse(myStoredShip[1])
 worldScripts["Ship_Storage_Helper.js"].disableVortexPBNSFunc(context)
 worldScripts["Ship_Storage_Helper.js"].disableMaelstromPBNSFunc(context)

Context must be a string – valid values are “delete” & “retainName”.

Used to temporarily modify the behaviour of the playerBoughtNewShip function in Thargoid's Vortex.oxp, to either prevent it running, or to prevent it renaming a Vortex or Maelstrom that has previously been stored.

 worldScripts["Ship_Storage_Helper.js"].enableVortexPBNSFunc()
 worldScripts["Ship_Storage_Helper.js"].enableMaelstromPBNSFunc()

Reverses the changes made by the above functions.

 worldScripts["Ship_Storage_Helper.js"].disableTCATPBNSFunc()
 worldScripts["Ship_Storage_Helper.js"].enableTCATPBNSFunc()

Used to temporarily disable the playerBoughtNewShip function in Thargoid's TCAT.oxp. Buying a new ship is a trigger for mission failure in this OXP, but this may not always be appropriate behaviour using the new methods.

All of these functions are called from Extended_Shipyards.OXP if you need examples of how they can be used.

Variables

 worldScripts["Ship_Storage_Helper.js"].dataKeyArray

This is an array of valid player ship dataKeys from the users currently installed OXPs. It is built at startUp. It is not necessarily comprehensive, and is less likely to be comprehensive the more unique player-flyable ships are installed. It can generally capture up to 60 to 70 unique dataKeys.

Download

Ship_Storage_Helper_0.38.oxz (downloaded 0 times).

Ship_Storage_Helper_0.37.oxz (downloaded 0 times).

Ship_Storage_Helper_0.36.oxz (downloaded 0 times).

Ship_Storage_Helper_0.35.oxz (downloaded 0 times).

Ship_Storage_Helper_0.34.oxz (downloaded 0 times).

Ship_Storage_Helper_0.33.oxz (downloaded 0 times).

Ship_Storage_Helper_0.32.oxz (downloaded 0 times).

Ship_Storage_Helper_0.31.oxz (downloaded 0 times).

Ship_Storage_Helper_0.30.oxz (downloaded 0 times).

Ship_Storage_Helper_0.29.oxz (downloaded 642 times).

Ship_Storage_Helper_0.28.oxz (downloaded 7741 times).

Ship_Storage_Helper_0.27.oxz (downloaded 1020 times).

Ship_Storage_Helper_0.26.oxz (downloaded 271 times).

Ship_Storage_Helper_0.25.oxz (downloaded 239 times).

Ship_Storage_Helper_0.24.oxz (downloaded 1322 times).

Ship_Storage_Helper_0.23.oxz (downloaded 740 times).

Ship_Storage_Helper_0.22.oxz (downloaded 353 times).

Ship_Storage_Helper_0.21.oxz (downloaded 1253 times).

Ship_Storage_Helper_0.21_2013.12.16.oxp.zip for Oolite 1.77.

ChangeLog

v0.38 31/05/22 - Fixed storage of ShieldCycler data. Fixed storage of non-core commodities. Damaged equipment now set in final passes. Added last chance attempt on adding equipment. Ensure player credit balance is the same after replacing ship.

v0.37 23/05/20 - Added support for Thargoids Repair Bots, and Breakable Lasers. Corrected issue with setting cargoSpaceCapacity too early (before cargo-space-adjusting equipment is installed). Fix for storing/restoring cargo from NPC ships, as well as the player ship. (Thanks to dybal for these bug fixes). Converted RTF file to text format.

v0.36 15/07/19 - Added a check for equipment already installed if installation function fails. Improved integration with Ship Configuration, reducing the chance of script timeouts.

v0.35 21/10/18 - Added a try/catch block to the missile selection routine, as it was still, occasionally, hitting the bug. Added support for Smugglers – The Galactic Underworld OXP.

v0.34 25/08/18 - Included a check for player bounty in case an equipment item has the “requires_clean” property set. Also tweaked the techLevel check to limit the looping, as well as reordered the sequence of checks to do the smaller loops first.

v0.33 22/08/18 - Attempt to fix issue with equipment conditions preventing items being added to the ship. Plus improved compatibility with UBER lasers in New Lasers OXP.

v0.32 09/06/18 - Fixed issue restoring ship.

v0.31 06/06/18 - Added Ship Configuration armour settings to the array.

v0.30 22/03/18 - Fixed issue with Ship Configuration Armour auto-repairing damaged equipment.

v0.29 31/12/17 – Fixed the restore of UBER lasers in new lasers, thanks to fraterchaos and phkb.

v0.28‭ ‬12/10/15‭ – ‬Removed beaconLabel restore due to read-only for player.

v0.27‭ 13‬/08/15‭ – Fixed a bug in ‬cargoSpaceCapacity handling‭.

v0.26‭ ‬06/08/15‭ – Added support for LMSS OXP. Fixed ‬liquor_wines, gem_stones, alien_items and ‭multiple passenger berths.

v0.25 01/08/15 - Save the new writable ship properties in Oolite 1.82. Use the new store function of Shield Cycler.

v0.24 13/04/15 - Fixed equipment restore if a required equipment comes later in the list. Fixed Shield Cycler cashback at ship restore.

v0.23‭ 10‬/01/15‭ ‬– Fixed equipment restore if the container OXP of an equipment is not exists anymore.

v0.22‭ 29‬/12/14‭ ‬– Use storedShipArray[14] for Carriers OXP and EscortDeck OXP by Norby and possible to handle NPC ships by calling storeCurrentShip‭(‬ship) and restoreStoredShip(storedShipString, ship‭).

v0.21 16/12/13 - Use keysForRole in Oolite 1.79 and a slightly improved buildDataKeyArray function in 1.77 (from Gallery OXP) to avoid memory problems if many OXP ships installed in machines with 4GB or less RAM.

Note: Use at least the 0.21 version to avoid memory problems if many OXP ships are installed.

v0.20 24/06/12 – Updated compatibility for v0.4 of Respray for Griff’s.oxp so that adjusted decals are correctly restored. Ensure that player shield strength is set to maximum on restore (thanks cim for the report).

v0.19 16/06/12 – Updated compatibility for v0.3 of Respray for Griff's.oxp

v0.18 09/06/12 – Added compatibility for v0.2 of Respray for Griff's.oxp

v0.17 05/06/12 - v.017 05/6/12 – Fixed a bug in handling of subEntities when the ship doesn’t have any.

v0.16 31/5/12 – Added additional information to header including system.name as a string, information about the station the ship is stored at, and the full price of the stored ship. Added entityPersonality as a ship attribute that is saved and can be restored (maintains paint colours on Griff's ships under full shaders). Thanks to cim for making this option available from trunk revision 4968. Fixed a bug were version 0.15 was unintentionally dependent on the Breakables OXPs.

Links


Not to be confused with