spawning a specific ship ?

General discussion for players of Oolite.

Moderators: winston, another_commander

Post Reply
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

spawning a specific ship ?

Post 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...

:)
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: spawning a specific ship ?

Post 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]”.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

Re: spawning a specific ship ?

Post 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]);
		}
}
User avatar
montana05
---- E L I T E ----
---- E L I T E ----
Posts: 1166
Joined: Mon May 30, 2016 3:54 am
Location: lurking in The Devils Triangle (G1)

Re: spawning a specific ship ?

Post 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
Scars remind us where we've been. They don't have to dictate where we're going.
User avatar
phkb
Impressively Grand Sub-Admiral
Impressively Grand Sub-Admiral
Posts: 4830
Joined: Tue Jan 21, 2014 10:37 pm
Location: Writing more OXPs, because the world needs more OXPs.

Re: spawning a specific ship ?

Post 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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Re: spawning a specific ship ?

Post by another_commander »

Debug console for the win. Use the :spawn console macro to generate any ship you want in-game.

Code: Select all

:spawn [ship-key]
or

Code: Select all

:spawn shipRole
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:

Code: Select all

T.setAI("dumbAI.plist")
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.
User avatar
cbr
---- E L I T E ----
---- E L I T E ----
Posts: 1422
Joined: Thu Aug 27, 2015 4:24 pm

Re: spawning a specific ship ?

Post 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

:D
Post Reply