storage.totalLabCount = 0 local labBaseSpeed = 1 local biolabBaseSpeed = 2 LabsScanned = false function GenerateLabInfo() for _, surface in pairs(game.surfaces) do local labs = surface.find_entities_filtered({type="lab"}) for index, lab in pairs(labs) do if lab.valid then storage.labs[index] = lab end end end end function GetEstimatedResearchTime() -- Base time in seconds for research local playerForce = game.forces["player"] local currentResearch = playerForce.current_research if not currentResearch then return end local researchName = currentResearch.name.."-"..currentResearch.level local researchTotalCost = currentResearch.research_unit_count * (currentResearch.research_unit_energy/60) local totalSpeed = storage.totalResearchSpeed local remainingPercentage = 1-playerForce.research_progress local remainingUnits = remainingPercentage*researchTotalCost local estimatedSeconds = remainingUnits/totalSpeed local returnSpeed = "---research-speed---\n"..totalSpeed.."\n" local returnTime = "---research-time---\n"..estimatedSeconds.."\n" local returnNameID = "---research-info---\n"..researchName.."\n" return returnSpeed..returnTime..returnNameID end function UpdateLabInfos() local totalLabs = 0 local totalSpeed = 0 totalLabs = #storage.labs for _, lab in pairs(storage.labs) do if lab.valid then if lab.status == defines.entity_status.working then local labBase if lab.name == "biolab" then labBase = biolabBaseSpeed else labBase = labBaseSpeed end local labSpeed = (labBase + (labBase * game.forces["player"].laboratory_speed_modifier)) * lab.effects.speed totalSpeed = totalSpeed + (labSpeed* (1+lab.effects.productivity)) --local labSpeed = labBaseSpeed * lab.effects.speed end end end storage.totalLabCount = totalLabs storage.totalResearchSpeed = totalSpeed end function SendResearchStats() if options.enableResearch == true then UpdateLabInfos() local researchTimeInfo = GetEstimatedResearchTime() if researchTimeInfo then helpers.send_udp(udpAddress, researchTimeInfo, serverIndex) end end end