Belt Balancer 2


Adds Balancer Parts, that can be put together, to balance all adjusting lanes. Updated for better performance and 2.0

Utilities
10 months ago
2.0
16.7K
Logistics

g Crashing when trying to remove a balancer

5 months ago
(updated 5 months ago)

error message says:
The mod Belt Balancer 2 (2.0.9) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event belt-balancer-2::on_player_mined_entity (ID 71)
belt-balancer-2/objects/part.lua:265: attempt to index local 'belt' (a nil value)
stack traceback:
belt-balancer-2/objects/part.lua:265: in function 'remove'
belt-balancer-2/control.lua:145: in function <belt-balancer-2/control.lua:134>

There's one standalone balancer causing this and also a group of 7, removing any crashes it. Routing any belts, underground belts or splitters into them also crashes. Force placing an item on top doesn't help either as well as any other method of removing them. For the time being I've quarantined off the area but it will make expanding a pain.

Any specific actions I can take to fix this or should I just wait for the next version of the mod?

5 months ago

Found a solution! Using the creative mod I placed a water tile over the glitched balancers, using the magic wand, which has successfully deleted them.

4 months ago
(updated 4 months ago)

modify belt-balancer-2/objects/part.lua

diff --git a/objects/part.lua b/objects/part.lua
index 5527515..687e2b4 100644
--- a/objects/part.lua
+++ b/objects/part.lua
@@ -260,6 +260,7 @@ function part_functions.remove(entity, buffer)

 for _, belt_index in pairs(part.output_belts) do
     local belt = storage.belts[belt_index]
  • if belt then

     -- only remove lanes, if this is splitter
     if belt.type == "splitter" then
    

    @@ -314,6 +315,8 @@ function part_functions.remove(entity, buffer)

     -- check if belt is still attached to a part
     belt_functions.check_track(belt_index)
    

    +
    + end
    end

    -- recalculate nth_tick, if no part is there, this will unregister the balancer

4 months ago

diff --git a/objects/part.lua b/objects/part.lua
index 5527515..687e2b4 100644
--- a/objects/part.lua
+++ b/objects/part.lua
@@ -260,6 +260,7 @@ function part_functions.remove(entity, buffer)
for _, belt_index in pairs(part.output_belts) do
local belt = storage.belts[belt_index]
+ if belt then
-- only remove lanes, if this is splitter
if belt.type == "splitter" then
@@ -314,6 +315,8 @@ function part_functions.remove(entity, buffer)
-- check if belt is still attached to a part
belt_functions.check_track(belt_index)
+
+ end
end
-- recalculate nth_tick, if no part is there, this will unregister the balancer

4 months ago

I didn't think to capture the error but I got something like this with using an uncommon balancer. Only normal quality seems safe.

3 months ago
(updated 3 months ago)

I have same bug. About 1/20 of the balancers are now bugged, and can't be deleted.

Once, I managed to delete a bugged balancer by placing other balancers next to it. But it only worked once. I now have 5 bugged balancers I can't delete.

I will try to remove the mod, add it back in, and rebuild all the balancers. :(

But yeah, trying to remove the balancer or remove or rotate the underground next to the balancer causes error:
"
The mod Belt Balancer 2 (2.0.9) caused a non-recoverable error.
Please report this error to the mod author.

Error while running event belt-balancer-2::on_player_mined_entity (ID 71)
belt-balancer-2/objects/part.lua:265: attempt to index local 'belt' (a nil value)
stack traceback:
belt-balancer-2/objects/part.lua:265: in function 'remove'
belt-balancer-2/control.lua:145: in function <belt-balancer-2/control.lua:134>
"

Let me know if you want my save file...

3 months ago
(updated 3 months ago)

I made this hack before I saw the comments above...

  1. Navigate to Factorio mods. On Windows: %appdata%\Factorio\mods

  2. Extract the zip. eg extract "belt-balancer-2_2.0.9.zip" as "belt-balancer-2_2.0.9"

  3. Rename the zip to hide it, eg "belt-balancer-2_2.0.9.zip.backup"

  4. Open "belt-balancer-2_2.0.9/objects/part.lua" and insert 4 lines of code (which commented with "CRASH FIX" below)

function part_functions.remove(entity, buffer)

...
for _, belt_index in pairs(part.input_belts) do
    local belt = storage.belts[belt_index]
    if not belt then goto continue_input end -- CRASH FIX
    ...
    ::continue_input:: -- CRASH FIX
end

for _, belt_index in pairs(part.output_belts) do
    local belt = storage.belts[belt_index]
    if not belt then goto continue_output end -- CRASH FIX
    ...
    ::continue_output:: -- CRASH FIX
end
...

end

3 months ago

Reply to @setoyoc
Tried doing this and the mod just would not turn back on and the save would request a sync. When I did not sync the balancers were removed. Tried placing a water tile under it and that did not work. Only solution atm is to uninstall, load, then reinstall and replace all missing balancers again.

3 months ago

Reply to @kaiokenmaster
Not sure, if you are desperate I have shared my whole mode folder here:
https://drive.google.com/drive/folders/14_u9r6K3SNsxcBw5BQPy7gSzN_HSr2Si
Only part.lua should be changed.

New response