Get stats of accumulators on the network
Get stats of accumulators on the network
Is there any way of getting information about the total accumulator charge of an electric network?
			
			
									
									
						Re: Get stats of accumulators on the network
I know that's a bit late, but maybe it will help someone it the future   
 
You'd think that would be a solution to this problem, but apparently it can only give producers and consumers.
Here's a code that finds every accumulator connected to the same network as some power pole, and returns total charge of this network
			
			
									
									
						 
 You'd think that
Code: Select all
electric_network_statisticsHere's a code that finds every accumulator connected to the same network as some power pole, and returns total charge of this network
Code: Select all
	local grid_id = <some_power-pole>.electric_network_id
	local total_charge = 0
	local accumulators = surface.find_entities_filtered{name = "accumulator"}
	for _, i in ipairs(accumulators) do
		if i.electric_network_id == grid_id then 
			total_charge = total_charge + i.energy
		end
	end
	game.print(total_charge)
- 
				FuryoftheStars
- Smart Inserter 
- Posts: 2766
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Get stats of accumulators on the network
Maybe a good request for modding interface request section? Assuming that one does indeed not already exist.TheBigZet wrote: Wed Nov 24, 2021 8:51 pm You'd think thatwould be a solution to this problem, but apparently it can only give producers and consumers.Code: Select all
electric_network_statistics
My Mods: Classic Factorio Basic Oil Processing | Sulfur Production from Oils | Wood to Oil Processing | Infinite Resources - Normal Yield | Tree Saplings (Redux) | Alien Biomes Tweaked | Restrictions on Artificial Tiles | New Gear Girl & HR Graphics
						
