Beacon Rebalance


Beacon rebalance mod that emulates the balance of Space Exploration's beacons, including the overload mechanic. (Now with Krastorio 2 and Bob's/SeaBlock compatibility!)

Tweaks
1 year, 3 months ago
1.1
16.6K

g Unlimited Productivity mod

2 years ago

As I found out, relying on the module slot count is NOT a reliable way to detect if a beacon is allowed to affect a machine or not. What determines that is the allowed effects field of the machine prototype. A machine CAN have zero module slots, AND still be allowed to be affected by a beacon.

Therefore, instead of this code.
local module_inventory = machine.get_module_inventory()
if module_inventory == nil or #module_inventory == 0 then return end

should be
local module_inventory = machine.get_module_inventory()
local allowed_effects = machine.effects
if (module_inventory == nil or #module_inventory == 0) and allowed_effects == nil then return end

When allowed_effects is not nil, it is a table structured like this.
["pollution", ["bonus", value],
"productivity", ["bonus", value],
"effectivity", ["bonus", value],
"speed", ["bonus", value]], minus any effects not allowed.

2 years ago

Machines powered by fuel rather than electricity that are allowed to have beacon effects get the best fuel utilization out of effectivity modules.

2 years ago

Interesting, I was under the impression that a machine needed module slots in order to be affected by a beacon. I'll fix that.

2 years ago

And now, if a beacon is placed and it sees the machines would be overloaded, it correctly overloads them, but in the case of the zero module machines, and you remove a beacon that is transmitting module effects, leaving JUST the beacon that isn't transmitting anything at all, the overload condition is NOT removed from the overloaded zero module machines. Also, One can still workaround it by placing multiple beacons, THEN loading the beacons with modules in the case of zero module machines, as it turns out, the effects ARE nil, if they are not currently being affected by anything at all.

As a result, the check needs to happen if the any of the beacons gets its module inventory changed at all.

2 years ago

Latest version should actually fix the issue. Now the script will check to see if the machine is affectable by beacons, not if it has module slots.

New response