Power+: Power Meter

by daydev

Adds a power meter combinator that directly outputs the percentage of power utilization in the electrical network over the four generation priorities.

Content
4 years ago
0.17 - 1.1
3.14K
Circuit network

b [Fixed] impending bugs: check `.valid` on Factorio API objects

5 years ago

I noticed that you don't check entities or surfaces for validity basically anywhere, which is going to break your code. Not quickly, but inevitably.

For everything that has a .valid field, which is pretty much anything from the Factorio API, make sure you check thing and thing.valid before you touch anything else on the object -- reading fields, or calling methods.

(also .valid_for_read if you want the content of something, which isn't relevant here, but seems worth mentioning overall.)

5 years ago

I bolstered the code, it should now be able to handle unexpected invalidation of meters and interfaces. Now watch it break =)

5 years ago

<3 should be fine as long as the fix didn't table.remove during a for loop on the same table. :)

New response