Eric Walch wrote:There is just one flaw left in the code:
Code: Select all
this.ShipDockedWithStation = function(station)
{
if (station.isMainStation)
{
mission.runScreen({title: "Automated GalCop Station Greeting", message: "Welcome, Commander"});
}
}
It does not check if another script already presented a mission screen. In that case this oxp would overwrite that screen. So, it needs an additional check:
Code: Select all
this.ShipDockedWithStation = function(station)
{
if (station.isMainStation && guiScreen != "GUI_SCREEN_MISSION")
{
mission.runScreen({title: "Automated GalCop Station Greeting", message: "Welcome, Commander"});
}
}
To avoid this type of problems, it is strongly advised to use the
missionScreenOpportunity
to display missionscreens. When your script gets a
missionScreenOpportunity
you can be sure no other script is using the missionscreen.

Which means that the better way of doing it would be:
Code: Select all
this.missionScreenOpportunity = function()
{
if (player.ship.isDocked && player.ship.dockedStation.isMainStation)
{
mission.runScreen({title: "Automated GalCop Station Greeting", message: "Welcome, Commander"});
}
}
@Massively Locked: two comments:
1) You notice that
player.ship.dockedStation
is back again. That's because the
missionScreenOpportunity
-handler does not have the handy
station
-parameter that can be used inside the function.
And 2) Thargoid's first comment is accommodated by adding a first check for whether the player is actually still docked at this point. This may seem superfluous at first glance, but experience has shown that it isn't, because there could be another script active that could have force-launched the player in-between calling the
missionScreenOpportunity
-handler and checking your condition.
(And by the way: Eric in his code transports an error introduced by submersible, so there were actually two flaws.

Can you spot it? Answer in the fine print.)
All reserved names in JS begin with a lowercase. Thus ShipDockedWithStation
must be [color=#FF0000]s[/color]hipDockedWithStation