However, four shalt thou not count.Thargoid wrote:or perhaps even ===Code: Select all
if(missionVariables.CockpitBought == null)
Scripters cove
Moderators: winston, another_commander
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
E-mail: [email protected]
- 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...
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
Question: Which events are called when the player enters a system through another ship's wormhole?
I've tried the shipWillExitWitchspace and the shipExitedWitchspace and they don't appear to be called, or, at least nothing is being written to my logs...
I can get a response from shipExitedWormhole, but that appears to be from the ship whose wormhole it was, not the player...
I've tried the shipWillExitWitchspace and the shipExitedWitchspace and they don't appear to be called, or, at least nothing is being written to my logs...
I can get a response from shipExitedWormhole, but that appears to be from the ship whose wormhole it was, not the player...
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
They should be called and I do get them in my log. The only time those events were missed when you were docked at a carrier and that carrier entered the system from witchspace. But that is fixed for 1.75Mauiby de Fug wrote:I've tried the shipWillExitWitchspace and the shipExitedWitchspace and they don't appear to be called, or, at least nothing is being written to my logs....
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
They're world events, so they need to be defined in Config/script.js ( or in a js file inside the Scripts directory, with a properly configured Config/worldScripts.plist ).
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
Yeah, I was calling them from a script assigned to a ship, and realized that that was why they weren't working! Although they are still listed under ship script event handlers, which was why I was getting confused...
There were a few other things I noticed on the reference pages which didn't seem to fit, but I can't remember what they were off the top of my head... Still, very useful pages! It did take me a while to find that player.ship.position was the way to access your position, which I got from someone's oxp; I would have thought it would be PlayerShip.position. I'm still getting my head around the various classes!
There were a few other things I noticed on the reference pages which didn't seem to fit, but I can't remember what they were off the top of my head... Still, very useful pages! It did take me a while to find that player.ship.position was the way to access your position, which I got from someone's oxp; I would have thought it would be PlayerShip.position. I'm still getting my head around the various classes!
Yes, it's 'a bit' tricky! Ship events relating to the player's ship are automatically world events.
Hmm, it might well be less confusing for new OXP makers if we had shipWillExitWitchspace only for NPC ship events & NPC ship scripts, & if we named the equivalent world script events playerWillExitWitchspace, etc...
It would mean yet more disruption for the existing scripts, though...
Hmm, it might well be less confusing for new OXP makers if we had shipWillExitWitchspace only for NPC ship events & NPC ship scripts, & if we named the equivalent world script events playerWillExitWitchspace, etc...
It would mean yet more disruption for the existing scripts, though...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
To add to the confusion: not all events for player ships go to the world event. e.g. for combat testing purposes in trunk I wanted a ship that did survive the tests for some time. When addingKaks wrote:Yes, it's 'a bit' tricky! Ship events relating to the player's ship are automatically world events.
Code: Select all
this.shipBeingAttacked = function(whom)
{
player.ship.forwardShield = player.ship.maxForwardShield;
player.ship.aftShield = player.ship.maxAftShield;
}
I think it would create confusion. because currently anything starting with player has no npc equivalent and anything starting with ship also goes to the player. The player does fly in a shipHmm, it might well be less confusing for new OXP makers if we had shipWillExitWitchspace only for NPC ship events & NPC ship scripts, & if we named the equivalent world script events playerWillExitWitchspace, etc...
There were some exceptions on this general rule though.
EDIT: and I just removed two handlers from the ship-handlers page that only fired for the player. (Both also started with player)
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:
Hm, I'm actually not so sure about that.Eric Walch wrote:EDIT: and I just removed two handlers from the ship-handlers page that only fired for the player. (Both also started with player)
If the handlers fire in a ship script, they should be documented. Off the top of my head I don't know, though, whether alertConditionChanged and playerEnteredNewGalaxy are sent to NPCs as well (they probably aren't, although I very much wanted alertConditionChanged to work for Personalities.oxp).
AlertConditionChanged applies to stations/carriers & players, if I remember correctly. We could add alert conditions to all ship entities, I suppose, even though we could end up with asteroids & splinters with alert levels too, which sounds a bit spooky...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
- Mauiby de Fug
- ---- E L I T E ----
- Posts: 847
- Joined: Tue Sep 07, 2010 2:23 pm
Re: Scripters cove
Question about event handling:
Say I've docked at a station, otherShipDocked() has been called, and is being processed. During this event, the ship is launched with player.ship.launch().
But what if there is an eventHandler for the ship launching in the stationLaunchedShip()? Will Oolite process the rest of the code for otherShipDocked first, and then do the stuff for stationLaunchedShip, or move to the stuff for stationLaunchedShip and continue the stuff for otherShipDocked afterwards? Also, is this behaviour consistent, or could it run differently each time? And what happens if multiple events are linked together this way?
Say I've docked at a station, otherShipDocked() has been called, and is being processed. During this event, the ship is launched with player.ship.launch().
But what if there is an eventHandler for the ship launching in the stationLaunchedShip()? Will Oolite process the rest of the code for otherShipDocked first, and then do the stuff for stationLaunchedShip, or move to the stuff for stationLaunchedShip and continue the stuff for otherShipDocked afterwards? Also, is this behaviour consistent, or could it run differently each time? And what happens if multiple events are linked together this way?
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Re: Scripters cove
It is certainly possible that a player gets a
At that moment, the player will be launched, generating launching events. When those are ready, the code continues the original code of docking and probably will send the
shipWillDockWithStation
() event and during that event is decides that it does not want to dock at such a station an issues a player.ship.launch()
command.At that moment, the player will be launched, generating launching events. When those are ready, the code continues the original code of docking and probably will send the
otherShipDocked(ship)
event to the station. When you want to be absolutely sure that the player has not launched in between, it still makes sense to check for "ship.docked == true
" in a handler that states that a ship is docking.UPS-Courier & DeepSpacePirates & others at the box and some older versions