Skip to content

Commit

Permalink
Local missions should list distances in AU rather than Ly
Browse files Browse the repository at this point in the history
In table of all player's accepted missions, display distance for
local deliveries in AU, and interstellar in LY.
  • Loading branch information
impaktor committed Feb 16, 2024
1 parent 60f643c commit 7efc2ce
Showing 1 changed file with 16 additions and 2 deletions.
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

0 comments on commit 7efc2ce

Please sign in to comment.