Page 4 of 4
Re: Adding ships - I don’t get it.
Posted: Mon Jun 04, 2012 8:02 pm
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.
Re: Adding ships - I don’t get it.
Posted: Mon Jun 04, 2012 8:15 pm
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.
Re: Adding ships - I don’t get it.
Posted: Mon Jun 04, 2012 8:25 pm
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…
Re: Adding ships - I don’t get it.
Posted: Mon Jun 04, 2012 8:56 pm
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.
Re: Adding ships - I don’t get it.
Posted: Mon Jun 04, 2012 9:21 pm
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.
Re: Adding ships - I don’t get it.
Posted: Tue Jun 05, 2012 8:16 am
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.
Re: Adding ships - I don’t get it.
Posted: Sun Jun 10, 2012 7:15 pm
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