player.ship.dockedStation is null error

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

Moderators: winston, another_commander

Post Reply
DGill
---- E L I T E ----
---- E L I T E ----
Posts: 292
Joined: Thu Jan 01, 2009 9:45 am

player.ship.dockedStation is null error

Post by DGill »

Occasionally get the following error:

10:00:17.669 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (buoyRepair 1.3.1): TypeError: player.ship.dockedStation is null
10:00:17.669 [script.javaScript.exception.unexpectedType]: ../AddOns/BuoyRepair1.3.1.oxp/Scripts/buoyRepair.js, line 73.

Any suggestions as to why the condition should return null rather than docked?

line 73 is: if(player.ship.dockedStation.hasRole("repaired-buoy-station"))
User avatar
Commander McLane
---- E L I T E ----
---- 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: player.ship.dockedStation is null error

Post by Commander McLane »

The error occurs when this line is executed while you're no longer docked anymore. Therefore there is no station you are docked at, and that means null.

Some if-clause has to be re-written or added to the script in order to avoid this scenario.
DGill
---- E L I T E ----
---- E L I T E ----
Posts: 292
Joined: Thu Jan 01, 2009 9:45 am

Re: player.ship.dockedStation is null error

Post by DGill »

OK, thanks
User avatar
Commander McLane
---- E L I T E ----
---- 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: player.ship.dockedStation is null error

Post by Commander McLane »

Commander McLane wrote:
Some if-clause has to be re-written or added to the script in order to avoid this scenario.
Sorry, I was a little brain-dead there. Of course it's not "some" if-clause, but the one from line 73 you're quoting. Changing it to

Code: Select all

if(player.ship.isDocked && player.ship.dockedStation.hasRole("repaired-buoy-station"))
should suffice.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: player.ship.dockedStation is null error

Post by Eric Walch »

DGill wrote:
Occasionally get the following error:

10:00:17.669 [script.javaScript.exception.unexpectedType]: ***** JavaScript exception (buoyRepair 1.3.1): TypeError: player.ship.dockedStation is null
10:00:17.669 [script.javaScript.exception.unexpectedType]: ../AddOns/BuoyRepair1.3.1.oxp/Scripts/buoyRepair.js, line 73.

Any suggestions as to why the condition should return null rather than docked?

line 73 is: if(player.ship.dockedStation.hasRole("repaired-buoy-station"))
I am a bit puzzled. The whole code of buoyRepair.js does not contain above line. Not in the current version 1.3.2 nor in an old version 1.2.5. "repaired-buoy-station" is the role of the station, but there is nowhere in the code a need to check if the player has docked at such a station.

The only check for a docked player is:

Code: Select all

	if (player.ship.docked)
    {
        this.buoyStatusTimer.stop();
    }
But there is never a check for a specific station, so it leaves me puzzled how you could find above quoted line 73?
DGill
---- E L I T E ----
---- E L I T E ----
Posts: 292
Joined: Thu Jan 01, 2009 9:45 am

Re: player.ship.dockedStation is null error

Post by DGill »

Ok, I'll get vrs 1.3.2 from Wiki and re-install

thanks
Post Reply