Power Overload


Performant, semi-realistic power distribution overhaul. Power poles can explode if the total electrical consumption on the network is too high. Use transformers to separate networks so that subnetworks do not take more power than they can handle.

Content
1 year, 2 months ago
1.1
3.07K
Power

i [Completed-1.2.0] ❤️ + fuses

3 years ago

This mod is rad and just what I was looking for.

Feature request: fuses, which are like small, overloading poles, but without the explosion, and are much cheaper than overloading-poles

3 years ago

I thought that you might like it! :D

My concern with that is surely everyone would just wire a fuse at the entrance to each subnetwork, meaning that no poles would ever overload, but it would be extra hassle to add another component each time? I was originally considering having one transformer for each pole type, which would also explode if it was transferring that amount of power (essentially an explosive fuse built into the transformer). This would have had a similar issue: it meant that the poles would never explode, unless you accidentally wired different types together.

Does that make sense? Do you agree? I've not decided either way

3 years ago

I have been experimenting with the mod but the high threshold is making testing difficult. Can you explain how to setup a trivial example using 2 EEIs?

3 years ago
(updated 3 years ago)

With the mod Editor Extensions installed, you can use this blueprint string. Connect the transformer to the poles (transformer connections currently can't be blueprinted) and increase the consumer above 100MW to watch the medium pole explode.

https://pastebin.com/7aUDtdiD

3 years ago

I did not realize that ALL the power poles exhibit this behavior now! Ok, this is easier to test now.

3 years ago

Ok, after some consideration, here are my thoughts:

I was able to blow up whole grids and multiple poles. The "Fuse" item should prevent that catastrophe.

If you were to implement a fuse, you'd need to be clear about how it operates. Perhaps the difference between an overloading-pole and a fuse is that
1) fuses are cheap
2) fuses prevent a cascade of failures.
3) fuses have a slightly lower threshold of overloading.

3 years ago

I imagine that fuses ACT like power-poles, but have a very tiny footprint. So if you have 4 tiers of poles, you'll need 4 tiers of fuses, each with 99% capacity of a same-tiered pole. This will ensure that the fuse blows first, protecting your grid.

3 years ago

I can see why they'd be useful, my concern is that they'd be too useful so that you'd never experience actual things exploding :)

3 years ago

I see... You WANT more explosions!

What a funny situation. Vanilla is too safe, so you made a mod that makes things more dangerous. Then I ask for a feature request to make the dangerous mod more SAFE...

Perhaps you could balance the fuses somehow. Maybe they are very expensive (instead of cheap) or something like that.

Perhaps the fuses have a threshold of 75%, rather than 99%. Now fuses "pop" far more frequently, making replacing them a pain.
Perhaps the fuses have an efficiency debuf. You can use them as a safety feature, but you lose 10% of the electricity that passes through them.

So maybe there's a tradeoff between using fuses and not-using-fuses. Fuses are safe, but low efficiency. Poles are dangerous but are lower maintenance and higher efficiency.

3 years ago

Oh, I like that! Yeah trade-offs is what I was looking for, so making them expensive and have a significantly lower threshold and efficiency debuf sounds great. (The efficiency debuf will just be them consuming ~10% of their maximum power limit.)

Now what base game entity graphics do I rip off to use for fuses... 🤔

3 years ago

(Tell me if I understand things correctly. I was reading your code and factorio modding is still hard for me, so bear with me.)

The solution came to me in a dream last night.

Every entity has a power buffer, which your mod uses to trigger an overloading pole. In vanilla, it governs the speed of any machine. With PowerOverload, poles die when this 100% is achieved.

My proposal:
1) Instead of simply "popping" and dying, poles just take damage and slowly fail.
2) Extend this behavior to every entity. Running anything at full power causes it to slowly fail.
3) Implement a "fuse" which works exactly as PowerOverload poles do, but with different graphics. It pops and dies.

Fuses are cheap, easy and safe. Balancing a grid is very very hard. It depends, I suppose, on the how much damage an entity takes per tick based on it's buffer.

3 years ago
(updated 3 years ago)

I'd like to +1 idea 1 of adam, it also came to mind upon seeing an entire network just go boom. That damage would be catastrophic in terms of resources and time and effort to recover, so slightly randomized progressing damage upon overload would make this much better. While a few power poles pop, the entire subnetwork will be heavily damaged, requiring quite the repair effort, but it doesn't send that particular part of the factory back into the stone age.

As for 2, I think this is probably out of scope for the mod and doesn't reflect IRL electricity either. Since we only work with wattage and not voltage, machines only draw as many Watts as they need in general. Also this behavior would be incredibly damaging early game, where a single boiler will be plenty to feed the base, and if you don't have enough consumers already produced and hooked up to the grid, goodbye progress.

3 is probably a good idea, with some slight penalties to encourage proper grid management instead of "slap fuse in front of everything". Although, isn't that what we do IRL all the time...? xD
Question is though, should they be expensive or is the temporary loss of a factory segment punishment enough?

3 years ago

Every entity has a power buffer, which your mod uses to trigger an overloading pole. In vanilla, it governs the speed of any machine. With PowerOverload, poles die when this 100% is achieved.

This isn't true. Entities that use power have a power buffer, power poles do not. This mod only uses the total network power consumption for deciding whether to explode a pole or not. It would be fairly straightforward to write a mod that uses the power buffer for each entity instead, but I agree with Zarukh that this is outside the scope of this mod. This mechanic wouldn't benefit from my implementation of transformers because they would only need regular power switches to regulate the electricity.

Idea 1 is good, and I'll add it as an option. I don't want to update every pole every second for UPS reasons so I think that it would still be random, but I'll make the damage get applied more often (and leave it as a setting to allow straight-up destroying poles as before).

Idea 3 (fuses) I will also add. They will be updated more often than power poles, so they should blow first, but they won't be an 100% solution (you may lose some power poles before they blow). They'll also have the lower threshold and constant power draw that we discussed earlier. I plan on making them fairly expensive because you won't need many of them and it adds to the loss, but in factorio, the individual cost of each item is almost irrelevant once you've automated its production. Also it can't require fancy ingredients because it will have to be craftable at the same time or soon after the associated regular power pole is available.

3 years ago

I understand your technique a lot better now, having spent the day playing around. If you'll get your mod on github, I can make a PR.

3 years ago

Ok, it is on Github now at https://github.com/tburrows13/PowerOverload. I'm working on more versatile modded pole support atm. Which bit specifically are you going to PR?

3 years ago
(updated 3 years ago)

Perhaps not a PR but just a branch I made.

 (╯°益°)╯  git remote -v                                                                                                   
origin  https://github.com/tburrows13/PowerOverload.git (fetch)
origin  https://github.com/tburrows13/PowerOverload.git (push)

 (╯°益°)╯  git push origin slowburn                                                                                        
remote: Permission to tburrows13/PowerOverload.git denied to adamwong246.
fatal: unable to access 'https://github.com/tburrows13/PowerOverload.git/': The requested URL returned error: 403

Could you check if I have permission to push to your repo?

3 years ago
diff --git a/control.lua b/control.lua
index 35fde73..b8ad7f9 100644
--- a/control.lua
+++ b/control.lua
@@ -121,6 +121,15 @@ script.on_event(defines.events.on_entity_destroyed,
           entity.destroy()
         end
       end
+
+      local pole_parts = global.poles[unit_number]
+      if pole_parts then
+        for _, entity in pairs(pole_parts) do
+          entity.destroy()
+          global.poles[unit_number] = nil
+        end
+      end
+
     end
   end
 )
@@ -148,21 +157,26 @@ local function update_poles()
       local consumption = get_total_consumption(pole.electric_network_statistics)
       local max_consumption = max_consumptions[pole.name]
       if max_consumption and consumption > max_consumption then
-        log("Pole being killed at consumption " .. consumption .. " which is above max_consumption " .. max_consumption)
+
+        local damageAmount = (max_consumption / consumption) * 10
+        log("Pole being damaged " .. damageAmount)
+
         local force = pole.force
         if force then
           for _, player in pairs(force.players) do
             player.add_alert(pole, defines.alert_type.entity_destroyed)
           end
           if settings.global["power-overload-log-to-chat"].value then
-            force.print({"overload-alert.alert", pole.name, math.floor(consumption)})
+            force.print({"overload-alert.alert", pole.name, damageAmount})
           end
         end
-        pole.die()
-        global.poles[i] = nil
+        -- pole.damage(1, 'player')
+        pole.damage(damageAmount, 'player')
+
+        -- global.poles[i] = nil
       end
     else
-      global.poles[i] = nil
+      -- global.poles[i] = nil
     end
   end
 end
@@ -230,4 +244,3 @@ script.on_init(
     end
   end
 )
-
diff --git a/locale/en/locale.cfg b/locale/en/locale.cfg
index 545f72e..430b4ad 100644
--- a/locale/en/locale.cfg
+++ b/locale/en/locale.cfg
@@ -21,4 +21,4 @@ po-transformer=Separates electric networks from each other
 power-overload-log-to-chat=Power pole explosion alerts in chat

 [overload-alert]
-alert=[entity=__1__] overloaded with __2__W
\ No newline at end of file
+alert=[entity=__1__] overloading with __2__W
3 years ago

I can work with the diff, but if you want to do it ‘properly’ then you don’t push to my repo, you fork it, push to your fork and open a PR from there.

3 years ago

that's true. I don't really want to maintain a fork tho just to collaborate but I could definitely just fork the whole repo.

3 years ago

Yeah, no maintenance necessary, once I've reviewed the changes and merged them you can delete your fork if you like.

3 years ago

I used your patch, and changed it quite a bit myself. It is now in 1.1.0 and you can see the result here: https://github.com/tburrows13/PowerOverload/commit/8acffb60ff7e4173dadc4b941dc38eb97d9909fd. Thanks for the help!

Fuses are coming next.

1 year, 11 months ago

Fuses are released now in v1.2.0!

New response