From 21b4d7a78c52d3e7ac7a48fa956ce916db9ee738 Mon Sep 17 00:00:00 2001 From: Luca_S Date: Sat, 9 May 2020 20:23:45 +0200 Subject: [PATCH] Set a default value for to.lockedToThis in the first iteration of the loop --- milo/apis/storage.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/milo/apis/storage.lua b/milo/apis/storage.lua index aaa0811..1855096 100644 --- a/milo/apis/storage.lua +++ b/milo/apis/storage.lua @@ -374,9 +374,9 @@ function Storage:defrag(throttle) -- are ruled out by the condition of the outer while loop for i = 2, #providers do -- 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] - 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] 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