Fixed rocket progress status

This commit is contained in:
Cooldude2606
2020-04-05 21:33:52 +01:00
parent 8569de50aa
commit 44a09d0991
3 changed files with 12 additions and 6 deletions

View File

@@ -33,7 +33,7 @@
]]
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
local format_number = _C.format_number --- @dep util
local format_number = require('util').format_number --- @dep util
local precision_index = defines.flow_precision_index
local Production = {}

View File

@@ -135,12 +135,14 @@ end
function Rockets.get_rolling_average(force_name,count)
local force = game.forces[force_name]
local rocket_count = force.rockets_launched
if rocket_count == 0 then return 0 end
local last_launch_time = rocket_times[force_name][rocket_count]
local start_rocket_time = 0
if count < rocket_count then
start_rocket_time = rocket_times[force_name][rocket_count-count+1]
rocket_count = count
end
return rocket_count > 0 and math.floor((game.tick-start_rocket_time)/rocket_count) or 0
return math.floor((last_launch_time-start_rocket_time)/rocket_count)
end
--- Event used to update the stats and the hui when a rocket is launched