BeltUpgrader not working

Place to get help with not working mods / modding interface.
Post Reply
LancerV
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed May 24, 2017 4:36 pm
Contact:

BeltUpgrader not working

Post by LancerV »

Have the BeltUpgrader mod installed and its always crashing at the same location:
__BeltUpgrader__/control.lua:379: attempt to get length of field 'neighbours' (a nil value)"

if #under.neighbours == 0 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

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: BeltUpgrader not working

Post by daniel34 »

Pretty sure this is the result of viewtopic.php?f=11&t=48176

The mod author should fix this themself, or you can just replace the #under.neighbours == 0 with under.neighbours = nil (not tested).
quick links: log file | graphical issues | wiki

LancerV
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed May 24, 2017 4:36 pm
Contact:

Re: BeltUpgrader not working

Post by LancerV »

Yeah that fixed it crashing but doesnt look it will upgrade them but better than nothing, thanks.

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: BeltUpgrader not working

Post by sparr »

should be "== nil"

I'm surprised "= nil" isn't throwing an error from trying to write to a read-only property.

LancerV
Manual Inserter
Manual Inserter
Posts: 4
Joined: Wed May 24, 2017 4:36 pm
Contact:

Re: BeltUpgrader not working

Post by LancerV »

I actually put ==nil without even thinking about it

sparr
Smart Inserter
Smart Inserter
Posts: 1327
Joined: Fri Feb 14, 2014 5:52 pm
Contact:

Re: BeltUpgrader not working

Post by sparr »

This patch will probably fix it, assuming the devs don't change it back to the more sensible "buggy" behavior before the mod authors get around to it.

Code: Select all

--- /Users/crisher/Downloads/BeltUpgrader_0.9.3/control.lua	2017-05-09 21:09:04.000000000 -0700
+++ /Users/crisher/Downloads/BeltUpgrader_0.9.3/control.lua.new	2017-05-24 15:49:04.000000000 -0700
@@ -376,7 +376,7 @@
 				--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 == 0 then --This is an orphaned underground belt
+					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)
@@ -386,16 +386,16 @@
 					-- 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 == 1 then
+					if under.neighbours.valid 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[1].position, inner_name=p.name, direction = under.neighbours[1].direction, type=under.neighbours[1].belt_to_ground_type, force=roboport.force}
+						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)
+						-- under.neighbours.order_deconstruction(force)

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

Post Reply

Return to “Modding help”