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

View file

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