Electric Network Statistics returning empty Dictionaries
Electric Network Statistics returning empty Dictionaries
Hello Factorio Forum!
I am Crimso, author of an accessibility mod with the goal of making Factorio completely accessible to the blind.
I am running into an issue where when I get the electric_network_statistics value of an electric pole, the output_counts and input_counts attributes are returning empty dictionaries. I am determining they are empty using both the # operator, and attempting to iterate through the entire dictionary with the pairs function.
I have also tried get_output_count for "steam-engine" "solar-panel" etc with no results.
Perhaps I am misunderstanding something fundamental, or perhaps a bug has been discovered? Any help would be greatly appreciated!
I am Crimso, author of an accessibility mod with the goal of making Factorio completely accessible to the blind.
I am running into an issue where when I get the electric_network_statistics value of an electric pole, the output_counts and input_counts attributes are returning empty dictionaries. I am determining they are empty using both the # operator, and attempting to iterate through the entire dictionary with the pairs function.
I have also tried get_output_count for "steam-engine" "solar-panel" etc with no results.
Perhaps I am misunderstanding something fundamental, or perhaps a bug has been discovered? Any help would be greatly appreciated!
Re: Electric Network Statistics returning empty Dictionaries
You didn't post the code that you tried.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Electric Network Statistics returning empty Dictionaries
local ent = players[pindex].tile.ents[1]
result = ent.name
result = result .. " " .. ent.type
if ent.type == "electric-pole" then
result = result .. #ent.neighbours.copper
if next(ent.electric_network_statistics.input_counts) == nil then
print("Abandon all hope ye who enter")
end
for i, v in ipairs(ent.electric_network_statistics.input_counts) do
print("Producer " .. i .. " " .. v)
end
end
if ent.prototype.electric_energy_source_prototype ~= nil and ent.is_connected_to_electric_network() == false then
result = result .. "Not Connected"
end
Hope this helps!
result = ent.name
result = result .. " " .. ent.type
if ent.type == "electric-pole" then
result = result .. #ent.neighbours.copper
if next(ent.electric_network_statistics.input_counts) == nil then
print("Abandon all hope ye who enter")
end
for i, v in ipairs(ent.electric_network_statistics.input_counts) do
print("Producer " .. i .. " " .. v)
end
end
if ent.prototype.electric_energy_source_prototype ~= nil and ent.is_connected_to_electric_network() == false then
result = result .. "Not Connected"
end
Hope this helps!
Re: Electric Network Statistics returning empty Dictionaries
I have the same issue in vanilla. Maybe we need to initialize something? Here's a one liner that I ran on a map with just a solar panel, small electric pole, and radar.
I did the same thing for output counts. They're both empty.
Code: Select all
/c game.player.print(#game.player.surface.find_entities_filtered{name="small-electric-pole"}[1].electric_network_statistics.input_counts)
Re: Electric Network Statistics returning empty Dictionaries
Not as much as if you indented properly and used code tags. Your code doesn't run.
players,
You never printed result so you don't see it.
Don't use ipairs for dicts. Use pairs for dicts.
Mouse over to select an entity and run this code in console (prefix "/c ")
Code: Select all
local ent = game.player.selected
local result = ent.name
result = result .. " " .. ent.type
if ent.type == "electric-pole" then
result = result .. #ent.neighbours.copper
if next(ent.electric_network_statistics.input_counts) == nil then
game.print("Abandon all hope ye who enter")
end
for i, v in pairs(ent.electric_network_statistics.input_counts) do
game.print("Producer " .. i .. " " .. v)
end
end
if ent.prototype.electric_energy_source_prototype ~= nil and ent.is_connected_to_electric_network() == false then
result = result .. "Not Connected"
end
game.print(result)
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Electric Network Statistics returning empty Dictionaries
Use table_size() to check size of dicts. You can't use # for that.Gweneph wrote: ↑Sun Jun 12, 2022 9:13 pmI have the same issue in vanilla. Maybe we need to initialize something? Here's a one liner that I ran on a map with just a solar panel, small electric pole, and radar.
I did the same thing for output counts. They're both empty.Code: Select all
/c game.player.print(#game.player.surface.find_entities_filtered{name="small-electric-pole"}[1].electric_network_statistics.input_counts)
Also, use game.player.selected and hover over a power pole to test code easier without having to start a world with only 1 electric pole.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Electric Network Statistics returning empty Dictionaries
my code is indented heavily because it is part of 3000 lines of code. It is printing to the command line prompt I am using to debug the program. I apologize if my formatting is wrong, I am blind and cannot see it. I used pairs initially and got the same result. Thanks for the help
Re: Electric Network Statistics returning empty Dictionaries
I tried your code and it didn't work. [Moderated by Koub : Please be civil, and don't start fights on this forum]
Edit: More specifically if anyone has had luck getting the output or energy producers tab of the electrical network statistics, I would be very grateful for a push in the right direction.
Edit2: If anyone else is having similar issues, make sure that the network in question has both producers and drainers on the electrical system or there will not be any contents in the input or output attributes.
Edit: More specifically if anyone has had luck getting the output or energy producers tab of the electrical network statistics, I would be very grateful for a push in the right direction.
Edit2: If anyone else is having similar issues, make sure that the network in question has both producers and drainers on the electrical system or there will not be any contents in the input or output attributes.
Re: Electric Network Statistics returning empty Dictionaries
Np
Why would you post that after?
And you didn't say what you tried. I got output on my computer because I tested it, if you want help then ask questions don't just say that working solutions don't work for you.
[Moderated by Koub : Response to a moderated content]
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
-
- Smart Inserter
- Posts: 2622
- Joined: Tue Apr 25, 2017 2:01 pm
- Contact:
Re: Electric Network Statistics returning empty Dictionaries
[Moderated by Koub : Response to a moderated content]
[Moderated by Koub : Response to a moderated content]. While you did say that you were working on something to make the game more accessible to the blind, you didn't say that you yourself were, so Qon had no way of knowing that you couldn't see the formatting.
[Moderated by Koub : Response to a moderated content]
Anyway...
[Moderated by Koub : Response to a moderated content]. While you did say that you were working on something to make the game more accessible to the blind, you didn't say that you yourself were, so Qon had no way of knowing that you couldn't see the formatting.
[Moderated by Koub : Response to a moderated content]
Anyway...
I gave Qon's code a try in exactly the manor they said to use it, and it works for me.
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
Re: Electric Network Statistics returning empty Dictionaries
[Moderated by Koub : Response to a moderated content]
I'm able to print simple stats mousing over a wooden power pole and running the following:
the output of which is
Can you clarify what player.tile and player.tile.ents is? The code that sets this would show well enough.
I'm able to print simple stats mousing over a wooden power pole and running the following:
Code: Select all
/c local ent = game.player.selected for k, v in pairs(ent.electric_network_statistics.input_counts) do game.print(k .. " " .. v) end
fast-inserter 10371.333065987
Re: Electric Network Statistics returning empty Dictionaries
[Moderated by Koub : Response to a moderated content]
Last edited by Qon on Mon Jun 13, 2022 12:31 am, edited 1 time in total.
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Electric Network Statistics returning empty Dictionaries
[Moderated by Koub : Response to a moderated content]
Re: Electric Network Statistics returning empty Dictionaries
[Moderated by Koub : Response to a moderated content]
My mods: Capsule Ammo | HandyHands - Automatic handcrafting | ChunkyChunks - Configurable Gridlines
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Some other creations: Combinassembly Language GitHub w instructions and link to run it in your browser | 0~drain Laser
Re: Electric Network Statistics returning empty Dictionaries
[Koub] I know this forum is on the Internet, so it's expected somehow that people call each others names and stuff, but that won't be under my watch. I removed all the fighting bits, and tried letting the good stuff. I advise everybody in here not to reactivate the fire.
Koub - Please consider English is not my native language.