Set a default value for to.lockedToThis in the first iteration of the loop
This commit is contained in:
@@ -374,9 +374,9 @@ function Storage:defrag(throttle)
|
|||||||
-- are ruled out by the condition of the outer while loop
|
-- are ruled out by the condition of the outer while loop
|
||||||
for i = 2, #providers do
|
for i = 2, #providers do
|
||||||
-- Give preference to locked chests
|
-- Give preference to locked chests
|
||||||
if not to.lockedToThis and providers[i].lockedToThis then
|
if not (to and to.lockedToThis or false) and providers[i].lockedToThis then
|
||||||
to = providers[i]
|
to = providers[i]
|
||||||
elseif (to.lockedToThis == providers[i].lockedToThis) and providers[i].item.count < providers[i].item.maxCount then
|
elseif ((to and to.lockedToThis or false) == providers[i].lockedToThis) and providers[i].item.count < providers[i].item.maxCount then
|
||||||
to = providers[i]
|
to = providers[i]
|
||||||
elseif providers[i].item.count == providers[i].item.maxCount then
|
elseif providers[i].item.count == providers[i].item.maxCount then
|
||||||
-- As this slot is already at maxCount, all the remaining ones will also be due to sorting
|
-- As this slot is already at maxCount, all the remaining ones will also be due to sorting
|
||||||
|
|||||||
Reference in New Issue
Block a user