Skip to content
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

Merged
merged 1 commit into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions data/pigui/modules/info-view/04-missions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,27 @@ local function makeMissionRows()
end

local playerSystem = Game.system or Game.player:GetHyperspaceTarget()
local dist = playerSystem:DistanceTo(mission.location)
local days = math.max(0, (mission.due - Game.time) / (24*60*60))

-- Use AU for interplanetary, LY for interstellar distances
local dist, dist_display
if mission.location:IsSameSystem(playerSystem.path) then
if mission.location:IsBodyPath() then
local body = mission.location:GetSystemBody().body
dist = Game.player:GetPositionRelTo(body):length()
dist_display = "\n" .. ui.Format.Distance(dist)
else
dist_display = "\n-"
end
else
dist = playerSystem:DistanceTo(mission.location)
dist_display = string.format("\n%.2f %s", dist, l.LY)
end

local row = {
mission:GetTypeDescription(),
mission.client.name,
locationName .. string.format("\n%.2f %s", dist, l.LY),
locationName .. dist_display,
ui.Format.Date(mission.due) .."\n".. string.format(l.D_DAYS_LEFT, days),
ui.Format.Money(mission.reward),
}
Expand Down