Can a script cancel a launch?

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

Moderators: winston, another_commander

Post Reply
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Can a script cancel a launch?

Post by byronarn »

Let's say I want a event to happen when the player goes to launch, and this event prevents the player from launching. Is there a way to do this?

For example a player is ready to launch, but right before he does, station security surrounds his ship and closes the hanger door before taking him into custody. Can this be scripted?

I was thinking it would go in the shipWillLaunchFromStation event handler. I just don't know a method that would cancel the launch.

Code: Select all

this.shipWillLaunchFromStation = function(station)
{
     // Your code here
}
User avatar
Norby
---- E L I T E ----
---- E L I T E ----
Posts: 2577
Joined: Mon May 20, 2013 9:53 pm
Location: Budapest, Hungary (Mainly Agricultural Democracy, TL10)
Contact:

Re: Can a script cancel a launch?

Post by Norby »

I do not know a cancel method, just a workaround which land back to the station immediately after launch. For example:

Code: Select all

this.shipLaunchedFromStation = function(station) {
  if(player.ship.fuel < 7) {
    station.dockPlayer();
    player.consoleMessage("Buy fuel before launch!", 10);
  }
}
Unfortunately dockPlayer do nothing in shipWillLaunchFromStation, which could be a way to cancel launch in time before the tunnel effect.

If you choose this workaround then also need a check if docking fees is installed and turn it off, like temporary rename the worldScripts["Docking Fees"].shipDockedWithStation function.
User avatar
byronarn
Dangerous
Dangerous
Posts: 85
Joined: Thu Nov 18, 2010 6:08 am
Location: United States

Re: Can a script cancel a launch?

Post by byronarn »

Norby wrote: Tue Mar 28, 2017 9:31 am
I do not know a cancel method, just a workaround which land back to the station immediately after launch. For example:

Code: Select all

this.shipLaunchedFromStation = function(station) {
  if(player.ship.fuel < 7) {
    station.dockPlayer();
    player.consoleMessage("Buy fuel before launch!", 10);
  }
}
Unfortunately dockPlayer do nothing in shipWillLaunchFromStation, which could be a way to cancel launch in time before the tunnel effect.

If you choose this workaround then also need a check if docking fees is installed and turn it off, like temporary rename the worldScripts["Docking Fees"].shipDockedWithStation function.
Tank you. I'll play around with it. :-)
Post Reply