Commander Xvyto wrote:Code: Select all
this.shipExitedWitchspace = function()
{
if(galaxyNumber==3 && system.name=="Esenis")
{
system.addShips("station", 1, player.ship.position, 8000);
}
}
How would I change the last two parameters of system.addShips() to give me a station behind the sun?
First of all, make sure you've read the relevant documentation, or at least are aware where to find it.
For
system.addShips
, see
here.
As you see, you need a vector expression for your position. There are several ways to calculate the vector:
You can do it in your script: Take the planet position. Construct a vector to the sun position. Make that vector longer, so that it points to a point behind the sun:
Code: Select all
var myVector = system.sun.position.subtract(system.mainPlanet.position); // this gives the vector from the planet to the sun
myVector = myVector.multiply(2); // this makes the vector longer by a factor of two
myVector = system.mainPlanet.position.add(myVector); // this gives you a position of equal distance exactly behind the sun, as seen from the planet
system.addShips("station", 1, myVector, 0); // you perhaps want it exactly in the calculated position, not randomly within a radius of 8000 meters
Or you can use a conversion method from the legacy coordinate system, which is part of the legacy scripting system. See
here. As you see, there is a choice of coordinate systems for your convenience. Obviously for placing a station relative to the planet and the sun, you need either ps
x or sp
x. Lets take ps
x. Now, which third parameter do you want to use? For getting the same result as with the first code, it makes sense to use u. Thus 'psu 0 0 2' is the exact coordinate you want (= the point that is exactly in line from the planet to the sun, at twice the distance between the former to = the point as far behind the sun as the sun is from the planet). Translated to the syntax of
fromCoordinateSystem this would be
Code: Select all
var myVector = Vector3D(0, 0, 2).fromCoordinateSystem("psu");
system.addShips("station", 1, myVector, 0);
or shorter
Code: Select all
system.addShips("station", 1, Vector3D(0, 0, 2).fromCoordinateSystem("psu"), 0);
Incidentally, this is exactly the same as
Code: Select all
system.addShips("station", 1, Vector3D(0, 0, -1).fromCoordinateSystem("spu"), 0);
I leave it to you to figure out why.
Commander Xvyto wrote:Edit: I changed the station it was spawning to one that was identical to the vanilla coriolis, except its ASC letter was Q. However, I now cannot dock with it without dying. I added the models (including the docking slit) to the models folder and the station and slit subent to the shipdata.plist. What's the problem?
There is a number of reasons I can think of. It would help if you'd post the shipdata snippets in question.