Only that this turns out to be a little harder than expected. Gladly, the legacy_addShips family is not deprecated and will continue to work, but still I would like to switch to cutting edge scripting. But here's the caveat: I am not yet completely happy with the new methods.
So this is not strictly a bug report, but some musings after testing and reflecting upon a new feature.
First: I am as happy as I could be about the methods returning the added ships. That was seriously missing from the legacy_ methods and will make scripting easier. If you want to do something to your freshly added ships you won't have to search for them first and put them in an array, but the array is already there. Yes!addShips
This method was added in Oolite test release 1.74.
function addShips(role : String, count : Number [, position: vectorExpression] [, radius: Number]) : Array
Adds ships to the system and returns the added ships in an array. Position is in absolute coordinates. When no position is given, the witchpoint is assumed. When no radius is given, the maximum scanner range is used. Ships added in range of the witchpoint automatically create a witchpoint entry cloud.
I am not quite so happy about the ships-added-at-the-witchpoint-automatically-create-a-cloud thing. Way back, when we discussed the ship adding methods, I asked for a seperate parameter which would determine the creation of a witch cloud. My reason is simple: In many cases you want to give the impression that another ship is waiting for the player at the witchpoint in order to assault him/her. That makes sense in-game: the attacker could have used a series of smaller jumps to "overtake" the player, and would have been lurking somewhere near the witchpoint for hours. But of course we can't spawn the NPC hours before the player enters the system. We have to do it exactly when the player enters. But what we explicitely do not want is to give the impression that the NPC has entered the system at the same time as or even after the player. In other words: we don't want it to pop up with a witch cloud. Now, in most cases this won't matter, as the NPC will very likely not be created in the player's field of view. But there is of course no guarantee for that, so in the few remaining cases the optical impression will spoil the intended effect. Therefore I still vote for explicit control of the cloud through the script, in other words: the addition of another parameter to the methods.
Then there is the small drawback that this method only accepts absolute coordinates. It is more an itching than a pain, but I thought I'd mention it anyway. Having other optional coordinate systems would make things sometimes easier. But as the new framerate-display also displays the abs coordinate you can always position your ship at the point you want to spawn something at and read the coordinates (and could anyway with the debug console), therefore just an itching.
Now here the itching gets more painful, because this method is a lot less powerful than the legacy_ methods. I have two points of pain:addShipsToRoute
This method was added in Oolite test release 1.74.
function addShipsToRoute(role : String, count : Number [, fraction: Number] [, route: String]) : Array
Adds ships to the system on certain common routes and returns the added ships as an array. The routes are the two character codes wp, pw, ws, sw, sp, and ps, where w stands for the witchpoint, p for the planet and s for the sun.
When no route is defined, the route witchpoint → main station is assumed.
The position is a fraction of the route and must be between 0 and 1. Unlike the legacy commands the fraction takes planetary radii in account, so it does not start counting in the centre of sun/planet but from its surface. When no fraction is defined, a random fraction is chosen. Ships are added within scanner range of this position. Ships added in range of the witchpoint automatically create a witchpoint entry cloud.
First, instead of three coordinates for x, y, and z direction there is only one parameter left. This means that this method cannot place anything outside the corridor. In many cases, however, we want to place something outside the corridor. An example from Anarchies.oxp: The Hacker Outpost is spawned at one of four random locations, depending on the system setup. The points of reference are always two of the three anchoring objects (witchpoint, planet, sun), but the Outpost is supposed to be difficult to find, so it cannot be placed directly in-between these points. Instead it is spawned somewhere in-between and a good distance perpendicular to the direct line. Very easily achievable with
Code: Select all
system.legacy_addShipsAtPrecisely("anarchies_hacker_outpost", 1, "psu", [0, 0.6, 0.5]);
My second pain point is the "and must be between 0 and 1". Why this unnecessary restriction? It didn't exist with the legacy_ methods. Again, a solar station cannot be added on the exact opposite side of the planet, which would be easy with route "ps" and a factor >1.
I guess this fell victim to the "takes planetary radii in account", which means that now a factor of 1.1 might be inside the planet (or sun), and only an unknown and ever differing value > 1 will put the object behind the planet. But personally speaking, I would rather not have this new feature and take care of not placing objects inside the planet or sun myself, than lose the ability to place objects behind the planet, witchpoint, or sun.
As I said, these are my personal musings as a scripter about a new functionality. Feel free to object, and: discuss.