Adding ships - I don’t get it.
Moderators: winston, another_commander
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I have two other things that I currently miss in the legacy_add series.
1) Present the added ships in an array as now already happens with the spawn() method. i find myself in a lot of situations were I add some ships and than have to do a find to get them in an array. But with a find you need all kind of checks to prevent already existing ships become also included.
2) When I add several ships in one command I would like to give them all the same group ID. Currently only pirates groups added by the populator have the same group ID. That makes that attacking one group member can trigger the others.
Probably we need also a addGroup() and a jumpInGroup() command. Same as the ship commands but now all with the same group ID. This would make the groupAttack commands work for script added groups of ships.
1) Present the added ships in an array as now already happens with the spawn() method. i find myself in a lot of situations were I add some ships and than have to do a find to get them in an array. But with a find you need all kind of checks to prevent already existing ships become also included.
2) When I add several ships in one command I would like to give them all the same group ID. Currently only pirates groups added by the populator have the same group ID. That makes that attacking one group member can trigger the others.
Probably we need also a addGroup() and a jumpInGroup() command. Same as the ship commands but now all with the same group ID. This would make the groupAttack commands work for script added groups of ships.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Yes, definitely. The legacy_foo functions will never do that, but the replacement will.Eric Walch wrote:1) Present the added ships in an array as now already happens with the spawn() method.
Makes sense.2) When I add several ships in one command I would like to give them all the same group ID. Currently only pirates groups added by the populator have the same group ID. That makes that attacking one group member can trigger the others.
Probably we need also a addGroup() and a jumpInGroup() command. Same as the ship commands but now all with the same group ID. This would make the groupAttack commands work for script added groups of ships.
One of my beyond-MNSR not-quite-plans is to rewrite the system populator in JavaScript, in a modular fashion. This basically means the new ship-adding functions need to be able to do everything.
E-mail: [email protected]
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Adding ships - I don’t get it.
Hi. I've read the posts about but don't understand them well. Would someone be kind enough to tell me how to convert the following into an 'addShips' command that generates witchspace rings, please? Thank you.
Code: Select all
system.legacy_addShipsWithinRadius("ferdelance3Military", number, "abs", player.ship.position, 6500);
Re: Adding ships - I don’t get it.
Code: Select all
system.addShips("ferdelance3Military", number, player.ship.position, 6500);
I came upon this accidentally the other day when coding the planet ring thingie. Initially I spawned them and then moved them, so when done on arrival from a witchspace jump the player ship ended up surrounded by very short-lived rings (the ring segments having already been moved to their positions by the script).
Looked quite pretty, albeit undesired.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Adding ships - I don’t get it.
Hi Thargoid
The method I mentioned does not seem to generate rings when used near the witchpoint. And, anyway, I wouldn't fancy having to spawn the ships near the wpoint and then instantly moving them to where I wanted them . .
EDIT: I think you have the addShips command in mind. I suppose I'll have to use addShips to put the ships near the witchpoint, and then shift them, and then add some hand-waving if anyone actually sees the transition.
The method I mentioned does not seem to generate rings when used near the witchpoint. And, anyway, I wouldn't fancy having to spawn the ships near the wpoint and then instantly moving them to where I wanted them . .
EDIT: I think you have the addShips command in mind. I suppose I'll have to use addShips to put the ships near the witchpoint, and then shift them, and then add some hand-waving if anyone actually sees the transition.
Re: Adding ships - I don’t get it.
Umm yes, I was thinking of addShips, hence the code above
For the other point - it's not necessary to spawn and then move, you can include the position in the addShips command. It was just in the code I originally had for the rings as I copy/pasted it from an older bit of scripting which didn't do it that way, but moved things later. But the result was that I got surrounded by wormholes when I triggered the code on arrival in a system, as the player ship was near the witchpoint then and was spawning the segments.
But to your original question - the legacy version doesn't generate wormholes, but the new one (which is what I suggested above, if you look carefully) does. The code I suggested is the addShips version of your original legacy one, which is what you asked for
For the other point - it's not necessary to spawn and then move, you can include the position in the addShips command. It was just in the code I originally had for the rings as I copy/pasted it from an older bit of scripting which didn't do it that way, but moved things later. But the result was that I got surrounded by wormholes when I triggered the code on arrival in a system, as the player ship was near the witchpoint then and was spawning the segments.
But to your original question - the legacy version doesn't generate wormholes, but the new one (which is what I suggested above, if you look carefully) does. The code I suggested is the addShips version of your original legacy one, which is what you asked for
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
-
- ---- E L I T E ----
- Posts: 1248
- Joined: Sat Sep 12, 2009 11:58 pm
- Location: Essex (mainly industrial and occasionally anarchic)
Re: Adding ships - I don’t get it.
Dear Thargoid
Thanks. (I managed to mistake the code you posted for a quotation of my code; or I just didn't see that code you presented at all; or. . something.)
Thanks. (I managed to mistake the code you posted for a quotation of my code; or I just didn't see that code you presented at all; or. . something.)
- SandJ
- ---- 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.
When, in testing, one wants to create some specific ships which only have common roles like 'pirate' or 'trader', how does one go about it?
If I understand correctly, the only way to do this (without editing the
It often results in messages in the Latest.log thus:
If I understand correctly, the only way to do this (without editing the
[size=120]shipdata.plist[/size]
to create a specific role for the ship) is to use [size=120]system.legacy_spawnShip("[i]shipDataKey[/i]")[/size]
- yes?It often results in messages in the Latest.log thus:
Code: Select all
10:58:11.197 [universe.spawnShip.error]: ***** ERROR: ***** ERROR: failed to find a spawn position for ship escortviper.
10:59:23.490 [universe.spawnShip.error]: ***** ERROR: ***** ERROR: failed to find a spawn position for ship BigBlimpy.
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Adding ships - I don’t get it.
No, legacy_spawnShip is to be only used for special ships that also contain an entry for position and orientation in the shipdata itself. For new stuff, just forget the method.SandJ wrote:If I understand correctly, the only way to do this (without editing the[size=120]shipdata.plist[/size]
to create a specific role for the ship) is to use[size=120]system.legacy_spawnShip("[i]shipDataKey[/i]")[/size]
- yes?
shipDataKey is not usable for adding ships. Unless you use latest trunk were it became possible. Not tested myself, but I am convinced it should work there by using the shipDataKey within brackets were normally a role is expected. e.g.
system.addShip("[shipDataKey]", 1)
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Commander McLane
- ---- 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.
What Eric said, which means that there's no other way than to edit shipdata.plist.
I am of the opinion that each ship should have a unique role anyway. However, for testing it's not always advisable to spawn it with its unique role. A ship spawned with "myRole" has some other behaviour than a ship spawned with "trader" or "pirate". Therefore you can't test everything with it.
Thus I'd suggest that, if you want to test it in one of the default roles, you should increase its weight in that role. If you want to see it as a trader, give it role "trader(10000)". That should make fairly sure that the next "trader" you're spawning will be your ship.
I am of the opinion that each ship should have a unique role anyway. However, for testing it's not always advisable to spawn it with its unique role. A ship spawned with "myRole" has some other behaviour than a ship spawned with "trader" or "pirate". Therefore you can't test everything with it.
Thus I'd suggest that, if you want to test it in one of the default roles, you should increase its weight in that role. If you want to see it as a trader, give it role "trader(10000)". That should make fairly sure that the next "trader" you're spawning will be your ship.
- SandJ
- ---- 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.
That's a bit of an error-prone faff. Would it be a useful feature for developers to be able to have a command available in the Debug Console so say "create [n] ships of type [blah]"?Commander McLane wrote:What Eric said, which means that there's no other way than to edit shipdata.plist.
Thus I'd suggest that, if you want to test it in one of the default roles, you should increase its weight in that role. If you want to see it as a trader, give it role "trader(10000)". That should make fairly sure that the next "trader" you're spawning will be your ship.
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
- Capt. Murphy
- Commodore
- Posts: 1127
- Joined: Fri Feb 25, 2011 8:46 am
- Location: UK South Coast.
Re: Adding ships - I don’t get it.
I can confirm that this functionality is available and fully operational in current nightly builds. If you examineEric Walch wrote:shipDataKey is not usable for adding ships. Unless you use latest trunk were it became possible. Not tested myself, but I am convinced it should work there by using the shipDataKey within brackets were normally a role is expected. e.g.system.addShip("[shipDataKey]", 1)
ship.roles
for any ship in trunk one of the valid roles will be its dataKey in square brackets. So every ship gets a guaranteed unique role whether the original author specified one or not. Capt. Murphy's OXPs
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
External JavaScript resources - W3Schools & Mozilla Developer Network
Win 7 64bit, Intel Core i5 with HD3000 (driver rev. 8.15.10.2696 - March 2012), Oolite 1.76.1
Re: Adding ships - I don’t get it.
You can make your own macros in the console, if you need that. But most people just need a single example of the ship, for whichSandJ wrote:That's a bit of an error-prone faff. Would it be a useful feature for developers to be able to have a command available in the Debug Console so say "create [n] ships of type [blah]"?
:spawn
does nicely (or :test
if you just want to view the model in a mission screen). A multiple ship macro would just be a variation on the spawn one, with it set to multiple entities.My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- SandJ
- ---- 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.
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).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.
Flying a Cobra Mk I Cobbie 3 with nothing but Explorers Club.OXP and a beam laser 4 proper lasers for company
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Dropbox referral link 2GB of free space online + 500 Mb for the referral: good for securing work-in-progress.
Re: Adding ships - I don’t get it.
The already noted [shipDataKey] role solves that - it will spawn that specifically defined ship and no other, regardless of any other roles it may have. That combined with the system.addShips command can give you any number of said ships, wherever you want them.
And if you use it frequently, you can define your own console macro for it. Or am I misunderstanding what you are after (which is quite possible today)?
And if you use it frequently, you can define your own console macro for it. Or am I misunderstanding what you are after (which is quite possible today)?
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link