Page 1 of 1

How to increase precision of displaying electricity consumption?

Posted: Tue May 12, 2020 11:11 pm
by Qeeet
I am currently testing nuclear power plant blueprints and decided to build my own. In order to test properly I need to know exactly how much electricity is produced/consumed.
Now it shows 2.7 GW. Theoretical production is 2720 MW.
Yes there is a mod where you can place pink accumulator and adjust its consumption. But it is not reliable as changing its power consumption will demand more power as it states until is stabilized.
AFAIK there is currently no solution to this simple trivial problem of just showing a full value with 3 decimals after '.' such as 2.720 would be seen, or is it?

Re: How to increase precision of displaying electricity consumption?

Posted: Wed May 13, 2020 12:15 am
by DaveMcW
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end

Re: How to increase precision of displaying electricity consumption?

Posted: Wed May 13, 2020 3:25 am
by Qeeet
DaveMcW wrote:
Wed May 13, 2020 12:15 am
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end
Thank you.

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 2:41 pm
by lyarain
DaveMcW wrote:
Wed May 13, 2020 12:15 am
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end
it does not work now . can u fix it ? or can i put code in a mod? thanks .

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 2:48 pm
by Xorimuth
lyarain wrote:
Thu Aug 25, 2022 2:41 pm
DaveMcW wrote:
Wed May 13, 2020 12:15 am
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end
it does not work now . can u fix it ? or can i put code in a mod? thanks .
Change one_second to five_seconds

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 3:02 pm
by lyarain
Xorimuth wrote:
Thu Aug 25, 2022 2:48 pm
lyarain wrote:
Thu Aug 25, 2022 2:41 pm
DaveMcW wrote:
Wed May 13, 2020 12:15 am
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end
it does not work now . can u fix it ? or can i put code in a mod? thanks .
Change one_second to five_seconds
332.png
332.png (66.3 KiB) Viewed 1439 times
changed,but error still.

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 3:54 pm
by Xorimuth
lyarain wrote:
Thu Aug 25, 2022 3:02 pm
Xorimuth wrote:
Thu Aug 25, 2022 2:48 pm
lyarain wrote:
Thu Aug 25, 2022 2:41 pm
DaveMcW wrote:
Wed May 13, 2020 12:15 am
You can run this code while hovering over a power pole.

Code: Select all

/c
precision = defines.flow_precision_index.one_second
network = game.player.selected.electric_network_statistics
for name, _ in pairs(network.input_counts) do
  energy = network.get_flow_count{name = name, input = true, precision_index = precision}
  game.print("Input - " .. name .. ": " .. energy * 59.8 .. " W")
end
for name, _ in pairs(network.output_counts) do
  energy = network.get_flow_count{name = name, input = false, precision_index = precision}
  game.print("Output - " .. name .. ": " .. energy * 59.8 .. " W")
end
it does not work now . can u fix it ? or can i put code in a mod? thanks .
Change one_second to five_seconds
332.png
changed,but error still.
You have to hover over a power pole

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 4:09 pm
by lyarain
Xorimuth wrote:
Thu Aug 25, 2022 3:54 pm

You have to hover over a power pole
tnanks i just clicked to open it. it works now.

Re: How to increase precision of displaying electricity consumption?

Posted: Thu Aug 25, 2022 4:35 pm
by FuryoftheStars