Scripters cove
Moderators: winston, another_commander
- 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:
- Cmd. Cheyd
- ---- E L I T E ----
- Posts: 934
- Joined: Tue Dec 16, 2008 2:52 pm
- Location: Deep Horizon Industries Manufacturing & Research Site somewhere in G8...
Guess I"m not understanding, as it doesn't seem that different to me. Then again, I've been studying for a certification for work for a few weeks, am in cram week now, and my brain has turned into tapioca...
Find my OXP's at:
Deep Horizon Industries - Your Planet Our Design
Deep Horizon Industries - Your Planet Our Design
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
spawn() has a bunch of special semantics. In particular:
- The generated ships have a random position inside the parent ship’s collision radius, and initially face outwards.
- The generated ships inherit 85 % of the parent’s temperature.
- If the parent is a missile and the spawned ship has the is_submunition property set, the spawned ship inherits the parent’s owner and target and is flagged as a missile. (Special case for smarter cluster missiles)
- Unlike addShip family methods, spawn() does not set up escorts, and does not handle auto-selection of trade routes and witchspace jump effects when it happens near a wormhole.
Last edited by JensAyton on Wed Feb 24, 2010 4:52 pm, edited 1 time in total.
E-mail: [email protected]
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
Hmm, after reading all this, I think Cmdr Cheyd's
... might be fitting for my purpose, too.
I want a sort-of beacon that spawns when a player ship does a certain action. It should spawn somewhere near the player ship and be able to have a station role (yes it's a workaround for something)
So addShipsWithinRadius should work, too.
Will try that first. Thanks all.
Code: Select all
system.legacy_addShipsWithinRadius('pirate', Num_Pirates, 'abs', player.ship.position, 25600);
I want a sort-of beacon that spawns when a player ship does a certain action. It should spawn somewhere near the player ship and be able to have a station role (yes it's a workaround for something)
So addShipsWithinRadius should work, too.
Will try that first. Thanks all.
You may also want to look at ship.ejectItem along similar lines perhaps (depending on what you want to do).
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
=== Power tip for mac users. ===
Working on RH I added some log() instructions to batter catch what was happening. While entering a certain mark system and doing something else I suddenly got the message that my mark was killed by someone else.
Looking in the log I found:
Apparently my mark just flew into the main station. Other logs told me he never started a fight so I thought at the inspect() method. I never realised you can use it somewhere else than in the console but when I gave my mark the following script:
the inspect window opened magically on entering a system with a mark. Without even seeing the ship I could see by the window it was heading to the station, When entering the station aegis it entered the state to go to the witchpoint. But the coordinates showed it was still heading for the station and again it killed itself by crashing into the station.
inspect() is very nice debugging command to remember for mac users.
Working on RH I added some log() instructions to batter catch what was happening. While entering a certain mark system and doing something else I suddenly got the message that my mark was killed by someone else.
Looking in the log I found:
Code: Select all
Mark was killed by: [Station "Coriolis Station" "Coriolis Station" ID: 252 position: (105472, 60671.7, 658999) scanClass: CLASS_STATION status: STATUS_ACTIVE] Because of: scrape damage. Last recorded hit: NPC_ATTACK
Code: Select all
this.shipSpawned = function ()
{
this.ship.inspect();
}
inspect() is very nice debugging command to remember for mac users.
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:
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Yep, the old line for going to the witchpoint was:Commander McLane wrote:Seems like an AI-bug, then...
Code: Select all
(setDestinationToWitchpoint, "setDesiredRangeTo: 1000.0", setDestinationToTarget, checkCourseToDestination)
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
A ship script question.
I assume it is the case, that when I have an "is template" ship, and the template ship gets a ship script attached (lets call it A.js), and if a ship later derived from that template via "like ship" has another ship script attached (say, B.js), then any ship derived from the template will normally have A.js, but the "like ship'ped" ship with the new one defined will have B.js because B.js will then override the template's A.js, yes?
I, as said, assume this is the case, just want to be really sure.
Edit: Second question, also, are death actions and ship scripts possible, simultanously? I seem to recall there was a problem with that in the past.
I assume it is the case, that when I have an "is template" ship, and the template ship gets a ship script attached (lets call it A.js), and if a ship later derived from that template via "like ship" has another ship script attached (say, B.js), then any ship derived from the template will normally have A.js, but the "like ship'ped" ship with the new one defined will have B.js because B.js will then override the template's A.js, yes?
I, as said, assume this is the case, just want to be really sure.
Edit: Second question, also, are death actions and ship scripts possible, simultanously? I seem to recall there was a problem with that in the past.
Yes, B.js will override A.js in the example.
And if the script also has death actions (or launch/spawn actions) then iirc those will also override any set in shipdata.
And if the script also has death actions (or launch/spawn actions) then iirc those will also override any set in shipdata.
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
OK, thanks!Thargoid wrote:Yes, B.js will override A.js in the example.
And if the script also has death actions (or launch/spawn actions) then iirc those will also override any set in shipdata.
Sorry if that detail is still not absolutely clear to me, but I can have both a death action and a ship script in the same entry and both will work, these two will not override each other?
- 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:
For the sake of simplicity I would suggest you move the death_actions from the shipdata into the ship script. That's what the shipDied event-handler in the ship script is for.
Concerning the overriding: If there is a shipDied event-handler in the ship script, it will override the death_actions in the shipdata. If no shipDied exists, it can't override anything, can it? Therefore the death_actions will be executed.
Concerning the overriding: If there is a shipDied event-handler in the ship script, it will override the death_actions in the shipdata. If no shipDied exists, it can't override anything, can it? Therefore the death_actions will be executed.
- Lestradae
- ---- E L I T E ----
- Posts: 3095
- Joined: Tue Apr 17, 2007 10:30 pm
- Location: Vienna, Austria
..
I assumed as much. But I believe to remember some discussion way back that ship scripts and death actions would generally collide somehow. Perhaps I misremember, perhaps this was the case in an earlier Oolite version?Commander McLane wrote:Concerning the overriding: If there is a shipDied event-handler in the ship script, it will override the death_actions in the shipdata. If no shipDied exists, it can't override anything, can it?
Whatever the case may be, thanks for the input, it is helpful.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
No. If there’s a ship script, it overrides any _actions.Lestradae wrote:Sorry if that detail is still not absolutely clear to me, but I can have both a death action and a ship script in the same entry and both will work
Wrong. The death_actions (and setup_actions, launch_actions, and script_actions) are run by the default ship script, oolite-default-ship-script.js. If you have a custom ship script, it replaces the default ship script completely.Commander McLane wrote:Concerning the overriding: If there is a shipDied event-handler in the ship script, it will override the death_actions in the shipdata. If no shipDied exists, it can't override anything, can it? Therefore the death_actions will be executed.
E-mail: [email protected]
- 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: