Belt Upgrader

by Mylon

Roboports automatically upgrade belts, splitters, underground belts, inserters, and assemblers within their reach.

Utilities
6 hours ago
0.14 - 2.0
20.0K
Logistics Logistic network

b Error while running event BeltUpgrader...

7 years ago
(updated 7 years ago)

I insalled the mod and after a while i got this Error:

Error while running event BeltUpgrader::on_tick (ID 0)
BeltUpgrader/control.lua:379: attempt to get length of field 'neighbours' (a nil value)

Would be great if there is a solution to this cause i love this mod and there is no similar one :D

7 years ago

Here is an fix for it if you edit the control.lua file

Starting at line 370
for n,p in pairs(global.unders) do
local maximum = roboport.logistic_network.get_item_count(p.name)
for i,under in pairs(beltlist) do
--game.print("Found an underground belt! Looking for replacement options.")
if maximum > 1 and count < maximum - 1 and p.belt_speed > under.prototype.belt_speed and p.max_underground_distance >= under.prototype.max_underground_distance then --Replace
--triggered = true
game.print("Underground belt replacement option found. Replacing with " .. p.name)
if not under.to_be_deconstructed(force) then
-- Check neighbor to see if we can replace at the same time.
if under.neighbours == nil then --This is an orphaned underground belt
local ghost = roboport.surface.create_entity{name="entity-ghost", position=under.position, inner_name=p.name, direction = under.direction, type=under.belt_to_ground_type, force=roboport.force}
table.insert(global.ghosts, ghost)
--under.order_deconstruction(force)
count = count + 1
break
end
-- We're assuming if it's in logistic range, it's in construction range.
-- This will cause some weird edge cases mods (super long underground belts or roboports with the same construction radius as logistic networks)
--if #under.neighbours == 1 and under.surface.find_logistic_network_by_position(under.position, force) then
if under.neighbours then

                    local ghost = roboport.surface.create_entity{name="entity-ghost", position=under.position, inner_name=p.name, direction = under.direction, type=under.belt_to_ground_type, force=roboport.force}
                    table.insert(global.ghosts, ghost)
                    -- under.order_deconstruction(force)

                    --Do Neighbor
                    local ghost = roboport.surface.create_entity{name="entity-ghost", position=under.neighbours.position, inner_name=p.name, direction = under.neighbours.direction, type=under.neighbours.belt_to_ground_type, force=roboport.force}
                    table.insert(global.ghosts, ghost)
                    -- under.neighbours[1].order_deconstruction(force)

                    count = count + 2
                    --game.print(count .. " " .. amount)

                    if count >= amount - 1 then --Out of bots.
                        return
                    end
                end
            end
        end
    end
end
7 years ago

Works perfectly!
Thanks alot!

7 years ago

I published an official fix for this. Thanks for providing an interim patch, LancerV.

New response