-
-
Notifications
You must be signed in to change notification settings - Fork 385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Local missions should list distances in AU rather than Ly #5756
Local missions should list distances in AU rather than Ly #5756
Conversation
e371463
to
d0b585d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Before accessing the result of
SystemPath:GetSystemBody()
you should check to make suremission.location:IsBodyPath()
is true. The location might be a path to a system rather than a body in that system, in which case the system body will benil
and dereferencing.body
will raise an error.
(Checking:IsSameSystem()
means that the system body will have a "physical" Body representation since the system it refers to is currently "reified", and thus you don't need to worry about nil-checking.body
.) - Use
ui.Format.Distance
to display any in-system distances (passing the raw distance to the target). It will handle dividing by meters/km/AU as needed and format the result accordingly. - Off the top of my head, we don't have a pre-built formatter for inter-system distances, so keeping the old
string.format
method for LY is fine.
1a37df6
to
647a303
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, if it's been tested then it gets my thumbs up. There's one variable name that should be changed before merge, but otherwise looks solid.
local systemBody = mission.location:GetSystemBody().body | ||
dist = Game.player:GetPositionRelTo(systemBody):length() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This body is not a SystemBody, it's just a regular Body. Would strongly recommend the variable not be named systemBody as that usually implies the type of the variable is actually the SystemBody returned from GetSystemBody().
(Variable names are important in dynamically-typed languages...)
647a303
to
d20e04d
Compare
In table of all player's accepted missions, display distance for local deliveries in AU, and interstellar in LY.
d20e04d
to
7efc2ce
Compare
When listing table of all player's accepted missions, local deliveries all have distance "0 ly". Switch to AU instead.
Fixes #5755
Demonstration
Pondering
mission.location:GetSystemBody()
return nil, and what should one display in that circumstance?