mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2025-12-31 04:51:40 +09:00
Fixed rocket progress status
This commit is contained in:
@@ -33,7 +33,7 @@
|
|||||||
]]
|
]]
|
||||||
|
|
||||||
local Colors = require 'utils.color_presets' --- @dep utils.color_presets
|
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 precision_index = defines.flow_precision_index
|
||||||
local Production = {}
|
local Production = {}
|
||||||
|
|||||||
@@ -135,12 +135,14 @@ end
|
|||||||
function Rockets.get_rolling_average(force_name,count)
|
function Rockets.get_rolling_average(force_name,count)
|
||||||
local force = game.forces[force_name]
|
local force = game.forces[force_name]
|
||||||
local rocket_count = force.rockets_launched
|
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
|
local start_rocket_time = 0
|
||||||
if count < rocket_count then
|
if count < rocket_count then
|
||||||
start_rocket_time = rocket_times[force_name][rocket_count-count+1]
|
start_rocket_time = rocket_times[force_name][rocket_count-count+1]
|
||||||
rocket_count = count
|
rocket_count = count
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
--- Event used to update the stats and the hui when a rocket is launched
|
--- Event used to update the stats and the hui when a rocket is launched
|
||||||
|
|||||||
@@ -73,11 +73,7 @@ Gui.element{
|
|||||||
local rocket_silo_name = element.parent.name:sub(8)
|
local rocket_silo_name = element.parent.name:sub(8)
|
||||||
local silo_data = Rockets.get_silo_data_by_name(rocket_silo_name)
|
local silo_data = Rockets.get_silo_data_by_name(rocket_silo_name)
|
||||||
if silo_data.entity.launch_rocket() then
|
if silo_data.entity.launch_rocket() then
|
||||||
silo_data.awaiting_reset = true
|
|
||||||
element.enabled = false
|
element.enabled = false
|
||||||
local progress_label = element.parent.parent[rocket_silo_name].label
|
|
||||||
progress_label.caption = {'rocket-info.progress-launched'}
|
|
||||||
progress_label.style.font_color = Colors.green
|
|
||||||
else
|
else
|
||||||
player.print({'rocket-info.launch-failed'},Colors.orange_red)
|
player.print({'rocket-info.launch-failed'},Colors.orange_red)
|
||||||
end
|
end
|
||||||
@@ -555,6 +551,14 @@ local function update_rocket_gui_progress(force_name)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Event used to set a rocket silo to be awaiting reset
|
||||||
|
Event.add(defines.events.on_rocket_launch_ordered,function(event)
|
||||||
|
local silo = event.rocket_silo
|
||||||
|
local silo_data = Rockets.get_silo_data(silo)
|
||||||
|
silo_data.awaiting_reset = true
|
||||||
|
update_rocket_gui_progress(silo.force.name)
|
||||||
|
end)
|
||||||
|
|
||||||
Event.on_nth_tick(150,function()
|
Event.on_nth_tick(150,function()
|
||||||
for _,force in pairs(game.forces) do
|
for _,force in pairs(game.forces) do
|
||||||
if #Rockets.get_silos(force.name) > 0 then
|
if #Rockets.get_silos(force.name) > 0 then
|
||||||
|
|||||||
Reference in New Issue
Block a user