Page 1 of 1
spawning a specific ship ?
Posted: Fri Mar 09, 2018 9:20 pm
by cbr
when a ship is painted, i start up oolite and go first to gallery ( very handy ) but the ship can still
look a little different ingame
So for educational purpose ingame viewing I would like to spawn a specific ship,
I am looking for script/code which spawns 5x the same ship on different positions at a radius of 3000 units surrounding the station
and which does this unconditional, so not 1 or 2 or 5 but 5...
Re: spawning a specific ship ?
Posted: Fri Mar 09, 2018 11:44 pm
by phkb
Does this help at all?
http://wiki.alioth.net/index.php/Oolite ... m#addShips
If you want a specific ship key to be spawned, make the role “[my-ship-data-key]”.
Re: spawning a specific ship ?
Posted: Sat Mar 10, 2018 12:18 am
by cbr
I am using this mischmasch mix, but it is not always certain a ship is spawned even after several station launches...
Code: Select all
"use strict";
this.shipLaunchedFromStation = function() {
var v1 = system.mainPlanet.position;
var v2 = system.sun.position.subtract(v1);
var v3 = v1.cross(v2).direction();
var v4 = v1.add(v3.multiply(system.mainPlanet.radius*1.5));
var md = system.addShips("medica",1,v4,10E3)[0];
var md = system.addShips("smivs-liner",4,system.mainStation.position,2E4)[0];
if (md) {
md.orientation = v3.multiply(-1).rotationTo([0,0,1]);
}
}
Re: spawning a specific ship ?
Posted: Sat Mar 10, 2018 4:04 am
by montana05
cbr wrote: ↑Sat Mar 10, 2018 12:18 am
I am using this mischmasch mix, but it is not always certain a ship is spawned even after several station launches...
This one is quite similar and easy to adapt, I am using it all the time to check my modifications:
Code: Select all
this.name = "GNSS Testrun";
this.author = "Montana05";
this.copyright = "This script is hereby placed in the public domain.";
this.version = "1.0";
this.description = "Spawns ships at the witchpoint or on W-P route after a witchspace jump."
this.shipWillExitWitchspace = function()
{
var pos1 = Vector3D(0, 0, -0.03).fromCoordinateSystem("wpu");
system.addShips("navy-behemoth-battlegroup", 1, pos1, 5000);
system.addShips("GNSS-leviathan_carrier_group", 1, pos1, 8000);
system.addShips("GNSS-condor_carrier_group", 1, pos1, 10000);
system.addShips("GNSS-orion", 1, pos1, 12000);
}
As you can see you can easily change the distance and number of ships you would like to spawn
Re: spawning a specific ship ?
Posted: Sat Mar 10, 2018 6:54 am
by phkb
Can I suggest, if you need to do test spawning of ships, that you investigate the JavaScript Debug Console? It makes your life so much easier when it comes to running test scripts. See this thread:
https://bb.oolite.space/viewtopic.php?t=4589
cbr wrote:
I am using this mischmasch mix, but it is not always certain a ship is spawned even after several station launches...
Remember, if you use
system.addShips("rolename", <etc>)
, Oolite will pick a random ship from any ship that has that role, based on the frequency, which means you might not get the ship you actually want. If you want a specific ship spawned, get the ship data key from the shipdata.plist file, and use the form
system.addShips("[shipdatakey]", <etc>)
instead.
Re: spawning a specific ship ?
Posted: Sat Mar 10, 2018 12:20 pm
by another_commander
Debug console for the win. Use the
:spawn
console macro to generate any ship you want in-game.
or
and you are set. If you want to approach the ship and admire it without worrying about it escaping (or opeining fire on you), you can spawn it and immediately execute on the console:
The T is an automatic variable that refers to whatever ship has just been generated.
When docked, you can also use the
:test
macro, which has the exact same parameters as :spawn (i.e. ship key in brackets or ship role) and creates a mission screen with the requested ship rotating in the middle. This is the best way of showing the ship in detail.
Re: spawning a specific ship ?
Posted: Sat Mar 10, 2018 2:14 pm
by cbr
Thanks for all the different options.
Currently using the 'oolite-debug-console-master' with pySimpleConsole.py and the ': spawn' command
which neatly adds the required ship in the current system