Add metrics combinator entity, GUI, and related functionality; enhance power and production stats tracking
Greatly improved train trip perfomance by culling table after sending Fixed formatting in many places
This commit is contained in:
@@ -12,8 +12,6 @@ function ScanLabs()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function UpdateLabs(event)
|
||||
local lab = event.entity
|
||||
if lab and lab.valid then
|
||||
@@ -28,8 +26,6 @@ function RemoveLab(event)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
function GetEstimatedResearchTime()
|
||||
-- Base time in seconds for research
|
||||
local playerForce = game.forces["player"]
|
||||
@@ -40,7 +36,8 @@ function GetEstimatedResearchTime()
|
||||
local researchName = currentResearch.name.."-"..currentResearch.level
|
||||
local researchTotalCost = currentResearch.research_unit_count * (currentResearch.research_unit_energy/60)
|
||||
|
||||
local totalSpeed = storage.totalResearchSpeed
|
||||
--local totalSpeed = storage.totalResearchSpeed
|
||||
local totalSpeed = GetCurrentResearchSpeed()
|
||||
|
||||
local remainingPercentage = 1-math.min(playerForce.research_progress,1)
|
||||
local remainingUnits = remainingPercentage*researchTotalCost
|
||||
@@ -81,9 +78,18 @@ function UpdateLabInfos()
|
||||
storage.totalResearchSpeed = totalSpeed
|
||||
end
|
||||
|
||||
function GetCurrentResearchSpeed()
|
||||
local totalResearch = 0
|
||||
local playerForce = game.forces["player"]
|
||||
if not playerForce then return end
|
||||
for _,surface in pairs(game.surfaces) do
|
||||
totalResearch = totalResearch + playerForce.get_item_production_statistics(surface).get_flow_count({name = "science", category = "input",precision_index = defines.flow_precision_index.five_seconds})
|
||||
end
|
||||
return totalResearch
|
||||
end
|
||||
|
||||
function SendResearchStats()
|
||||
if options.enableResearch == true then
|
||||
UpdateLabInfos()
|
||||
local researchTimeInfo = GetEstimatedResearchTime()
|
||||
if researchTimeInfo then
|
||||
helpers.send_udp(udpAddress, researchTimeInfo, serverIndex)
|
||||
|
||||
Reference in New Issue
Block a user