fix: Remove delay after successfully moving an item

This commit is contained in:
Jiří Štefka 2024-10-17 21:19:24 +02:00
parent da8fcd7ca8
commit ba8376e42e

@ -84,7 +84,6 @@ function loadIndex()
local itemIndex local itemIndex
local db = fs.open(settings.get("ccVault.file"), "r") local db = fs.open(settings.get("ccVault.file"), "r")
if not db then if not db then
-- printError("Couldn't open DB file!\n" .. settings.get("ccVault.file"))
print("Index file not found. It probably wasn't created yet.") print("Index file not found. It probably wasn't created yet.")
local iCount = 0 local iCount = 0
write("Waiting until indexing is finished") write("Waiting until indexing is finished")
@ -128,7 +127,6 @@ function storageLoop()
item = nil item = nil
count = nil count = nil
end end
sleep(2)
term.clear() term.clear()
term.setCursorPos(1, 1) term.setCursorPos(1, 1)
end end
@ -146,18 +144,22 @@ function transfer(tItem, maxCount, itemIndex)
end end
if not exists then if not exists then
print("Item not found.\nTry to wait for index update.") print("Item not found.\nTry to wait for index update.")
sleep(3)
return return
end end
local sItemInfo = peripheral.call(itemIndex[tItem][1]["chest"], "getItemDetail", itemIndex[tItem][1]["slot"]) local sItemInfo = peripheral.call(itemIndex[tItem][1]["chest"], "getItemDetail", itemIndex[tItem][1]["slot"])
if not sItemInfo then if not sItemInfo then
print("Index is out of date!\nWait for index update to resolve this error.") print("Index is out of date!\nWait for index update to resolve this error.")
sleep(3)
return return
elseif sItemInfo.count <= 0 then elseif sItemInfo.count <= 0 then
print("Index is out of date!\nWait for index update to resolve this error.") print("Index is out of date!\nWait for index update to resolve this error.")
sleep(3)
return return
elseif not sItemInfo.count then elseif not sItemInfo.count then
print("Index is out of date!\nWait for index update to resolve this error.") print("Index is out of date!\nWait for index update to resolve this error.")
sleep(3)
return return
end end
@ -165,6 +167,7 @@ function transfer(tItem, maxCount, itemIndex)
if not itemIndex[tItem][1] then if not itemIndex[tItem][1] then
if transfered > 0 then if transfered > 0 then
print("Not enough of `" .. tItem .. "` was found.\nTransfered only " .. transfered .. ".") print("Not enough of `" .. tItem .. "` was found.\nTransfered only " .. transfered .. ".")
sleep(3)
end end
break break
end end
@ -174,6 +177,7 @@ function transfer(tItem, maxCount, itemIndex)
if lastSlot then if lastSlot then
if lastSlot.count > 0 then if lastSlot.count > 0 then
print("Output inventory is full!") print("Output inventory is full!")
sleep(3)
return return
end end
end end
@ -188,12 +192,14 @@ function transfer(tItem, maxCount, itemIndex)
elseif moved == 0 then elseif moved == 0 then
if peripheral.call(settings.get("ccVault.outputInventory"), "size") == transfered then if peripheral.call(settings.get("ccVault.outputInventory"), "size") == transfered then
print("Output inventory is full!") print("Output inventory is full!")
sleep(3)
break break
else else
table.remove(itemIndex[tItem], 1) table.remove(itemIndex[tItem], 1)
end end
elseif not moved then elseif not moved then
print("Item not found!") print("Item not found!")
sleep(3)
break break
else else
transfered = transfered + moved transfered = transfered + moved