Repository navigation
Does player.ship ever not exist? #723
Replies: 2 comments
|
In my testing, Then start a new game, launch, then spin around a ram the station for an instant death. Then check your log file. This is what I see:
So, during the shipTakingDamage event, the player ship is valid, even though the event is literally killing the player. But in shipDied, the player ship isn't valid any more. As for player.ship.position, in one run of that test, I got no other errors in the log. But in the last instance, I saw this:
What has happened here, is that another worldscript or ship script event has fired after the player ship died. I have seen similar errors coming from the Custom Shields mod. So, player.ship.position can be undefined in some circumstances, generally speaking during events that aren't directly linked to player actions (repopulator functions, ship script events, timer functions, that sort of thing). However, player.ship.isValid should be false at the same time that player.ship.position is undefined. Hopefully that all makes sense. |
|
Great stuff. Thank you very much. |
Uh oh!
There was an error while loading. Please reload this page.
Dear all
I am wondering whether some of the checks in the following - which occurs within a repopulator Javascript function - are redundant.
if (!player.ship || !player.ship.isValid || !player.ship.position) return;Thanks.
All reactions