Adding ships - I don’t get it.

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Adding ships - I don’t get it.

Post by Commander McLane »

SandJ wrote:
Thargoid wrote:
Most people just need a single example of the ship, for which :spawn does nicely. A multiple ship macro would just be a variation on the spawn one, with it set to multiple entities.
But that gives any ship from the role, and if it is a rare trader or a pirate that is required, spawning dozens of ships hoping to get the one you want is tedious (as I have found today).
Which is why I suggested that you increase the role weight of the ship you want to test.
User avatar
SandJ
---- E L I T E ----
---- E L I T E ----
Posts: 1048
Joined: Fri Nov 26, 2010 9:08 pm
Location: Help! I'm stranded down here on Earth!

Re: Adding ships - I don’t get it.

Post by SandJ »

Thargoid wrote:
am I misunderstanding what you are after (which is quite possible today)?
You do understand. I will wait for [size=120]system.addShips("[key]",n,posn)[/size] in v1.76.2 or whatever released version it will appear in.
Commander McLane wrote:
Which is why I suggested that you increase the role weight of the ship you want to test.
Which requires editing the plist, restarting the game, getting into a suitable position for testing, launching sufficient ships to get the one you want (which, granted, will usually be the first one), then remembering to put the plist back, and remembering what the value was, then restarting the game, then doing the next test... As I said, an error-prone faff.
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company :D
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Adding ships - I don’t get it.

Post by Commander McLane »

SandJ wrote:
Commander McLane wrote:
Which is why I suggested that you increase the role weight of the ship you want to test.
Which requires editing the plist, restarting the game, getting into a suitable position for testing, launching sufficient ships to get the one you want (which, granted, will usually be the first one), then remembering to put the plist back, and remembering what the value was, then restarting the game, then doing the next test... As I said, an error-prone faff.
Well, nobody said that testing OXPs wasn't work. :)

And I repeat what I said before: even if you wait for Oolite 1.77 before testing your ship (which could take another year or so), spawning a ship by its shipdata key (or any unique role) will not produce the same result as spawning it by role "trader" or "pirate". For instance, the ship will not be attacked by pirates, because its unique role isn't included in pirate-victim-roles.plist. And you don't want to edit plists…
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Adding ships - I don’t get it.

Post by Eric Walch »

Commander McLane wrote:
spawning a ship by its shipdata key (or any unique role) will not produce the same result as spawning it by role "trader" or "pirate". For instance, the ship will not be attacked by pirates, because its unique role isn't included in pirate-victim-roles.plist. And you don't want to edit plists…
At least that part can be 'fixed' by giving it a new primary role and correct AI after spawning. And when you have to repeat it often, you can define a macro that adds a ship AND gives it the right properties.
User avatar
SandJ
---- E L I T E ----
---- E L I T E ----
Posts: 1048
Joined: Fri Nov 26, 2010 9:08 pm
Location: Help! I'm stranded down here on Earth!

Re: Adding ships - I don’t get it.

Post by SandJ »

Commander McLane wrote:
Well, nobody said that testing OXPs wasn't work. :)
Good point. I'll stop using the Debug Console too and do my testing properly. :roll:

Image
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company :D
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Adding ships - I don’t get it.

Post by Thargoid »

The problem will be that you can only (currently) pass one parameter in the console.

For example the :spawn macro is defined as this.T = system.addShips(PARAM, 1, player.ship.position, 10000);, where PARAM is the passed parameter (the role to be spawned in this case).

So what you could do is for example define your own parameter using :setM which spawns 10 ships of the given role (something like :setM spawn10 this.T = system.addShips(PARAM, 10, player.ship.position, 10000); - where 10 is obviously the number of ships, player.ship.position is the centre of the sphere in which they are spawned (your ships current position in this case) and the 10000 is the radius of said sphere). The position and radius of course can be changed if you wish when you set the macro up.

You can then access the ships via the this.T, which will be an array in this case as there are multiple ships (so this.T[0] or just T[0] will be the first of the ships, this.T[9] or T[9] will be the 10th and last). You can use that to change the ship once spawned, for examples T[2].primaryRole = "<myrolehere>"; or T[4].setAI("dumbAI.plist"); will change the primary role of the 3rd ship to whatever you put in <myrolehere> or the 5th ship's AI to dumbAI.

The shipdata key role is coming in v1.77 (and is already in the trunk nightlies) and with a little macro creation should cover your needs. For 1.76.x, you'd need to edit the shipdata.plist of the ship you're interested in, and if it doesn't already have a unique role in its list then give it one temporarily.

If you want to know the list of current macros in the console, either use the :listM command in the console, or for the more manual approach look in debugConfig.plist in the config folder of basic-debug.oxp. The built-in macro definitions start around line 56.
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Re: Adding ships - I don’t get it.

Post by JensAyton »

Thargoid wrote:
The problem will be that you can only (currently) pass one parameter in the console.

For example the :spawn macro is defined as this.T = system.addShips(PARAM, 1, player.ship.position, 10000);, where PARAM is the passed parameter (the role to be spawned in this case).
Since PARAM contains everything after the macro name, you can parse it in a macro. For example:

Code: Select all

:setM spawnN (function(){ let params = PARAM.split(" "); this.Ts = system.addShips(params[0], params[1], PS.position, 10000);})()
// Usage: :spawnN pirate 5
Post Reply