I can assign a custom script to a ship by doing myship.setScript("myshipscript.js"). I think I'm correct in saying if another OXP has got there ahead of me, doing that command will wipe out any existing script and replace it with mine. Is is possible to append my script to the existing one? For example, the existing script might have the following custom function:
As some of you already know I try to write an additional cargo space workaround script for Oolite 1.83.
Reason behind and current status of the script: There is currently no way to add cargo space, that survives a game state reload. That workaround script should create a common way for OXPs to preserve it.
Currently my script restores the added cargo space value (theoretically for several OXPs using it) in the startUp()-phase. Sadly, if that space was used for commodities and/or equipment, those items don't survive the loading process of the game engine, too. (They are omitted, when building the ship from the savegame, as the at that point too small standard cargo space isn't sufficient for them. The additional space is added too late.) The script saves them in missionVariables and restores them in the startUp()-phase, too. I'm current implementing the restoration of the equipment.
I have come across a problem with the Passenger Berths. In some cases (read above) the berths are not added to the ship when loading a savegame. Passenger contracts using them are omitted, too. Now I want to save and restore them by using missionVariables.
Regarding this I have 3 questions:
Q1: If a contract is dropped in such a way (just not being restored), are there any negative consequences for the pessanger transportation reputation of the player? (I already checked the savegames, but reputation is a complex affair. If somebody knows a sure answer, this would help.)
Q2: I didn't find any clues on how to read out contract data (passenger's name, destination, fee, advanced payment, arrival time, aso.) in-game with java methods. How do I get them?/Where are they hidden?
Q3:The addPessanger method doesn't provide an argument for the start date of the contract. The current game time is taken instead. How does the start date influence the contract? (Boni/Mali for arriving early or late?)
Q2: I didn't find any clues on how to read out contract data (passenger's name, destination, fee, advanced payment, arrival time, aso.) in-game with java methods. How do I get them?/Where are they hidden?
Thx. 1 problem down, 2 left. I already searched through Oolite JavaScript Reference: Ship, but somehow didn't find it. Now I can implement it.
@Q1: I hope it doesn't hurt the reputation, but at least, in case it does, I have player.increasePassengerReputation(). Still if somebody knows something, it would save me crawling through the sourcecode.
@Q3: I'll have to test that, but I guess if it does change things, there is nothing I can do. Again. If somebody already has experience in this matter, your input can't hurt
What would I need to do to recreate the planet descriptions for all the planets? For instance, if I wanted to (in my personal Ooniverse) eliminate "edible poets" from planetary descriptions, could I edit the "descriptions.plist" file and then run some code to output a new description to the log file or something?
Does anybody know the formula to calculate the mass-lock distance for planets and suns? I should do this for the NPC ship during torus synchronisation, as well in Escorts Contracts as in my new OXP.
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"
Does anybody know the formula to calculate the mass-lock distance for planets and suns?
Planets from planet.position: planet.radius + Math.max( planet.radius, 25600 )
Is not always 2*radius due to there are small moons (planet.hasAtmosphere==false) where the masslock radius is at least the normal scanner range over the surface.
Sun from system.sun.position: system.sun.radius * Math.sqrt(2)
planet mass and an oolite-specific gravitational constant...
Both planet.mass and sun.mass return 0 - seems calculated from the volume for ships only.
There is no gravity in Ooniverse so the "constant" is 0 also.
What would I need to do to recreate the planet descriptions for all the planets? For instance, if I wanted to (in my personal Ooniverse) eliminate "edible poets" from planetary descriptions, could I edit the "descriptions.plist" file and then run some code to output a new description to the log file or something?
If you just wanted to substitute a component in the current algorithm, then either a find-and-replace on planetinfo.plist, or a little bit of Javascript that makes the change by updating System.infoForSystem(g,s).description for the affected systems, would probably be the easiest approach.
You could also download/compile Oolite 1.77.1, update its descriptions.plist, and output the system descriptions as they get procedurally generated to the log (you'll need to do this once per galaxy since reading from other galaxies was a consequence of not procedurally generating everything)
Really big changes are probably easiest to make by writing a separate generator script, running it, and saving the result as a planetinfo.plist.
system.addShips() can add ships with a certain role. I don't know where I have read it (it isn't documented in the wiki), but the method can also add ships of a certain type if the type name is enclosed in square brackets. But in the latter case, the ships don't seem to have a role, which can be bad for testing. I wonder if there is a possibility to add ships of a certain type in a specific role, like, for example, a Boa trader?
"You wouldn't kill me just for a few credits, would you?" – "No, I'll do it just for the fun!"