vines/turtle.lua: dig cooldown
authorOlav Bakke Svendsen <mail@olavbs.no>
Tue, 14 May 2024 12:56:20 +0000 (14:56 +0200)
committerOlav Bakke Svendsen <mail@olavbs.no>
Tue, 14 May 2024 12:56:20 +0000 (14:56 +0200)
vines/turtle.lua

index 1a1201a708856e97d2cd405f0e2b921f6a078178..66af0cc0c6d28e422e6147486927aabb7d6eab34 100644 (file)
@@ -97,7 +97,7 @@ local transferAndSelect = function(i, t)
   if i < 1 or i > 16 then return false, msg .. "Index out of range" end
   -- if a wanted item already is in the wanted slot, select it and return early
   local item = turtle.getItemDetail(i)
-  if oneOf(t, item.name) then
+  if item and oneOf(t, item.name) then
     turtle.select(i)
     return true
   end
@@ -131,6 +131,10 @@ local harvest = function()
   local selected, select_error = transferAndSelect(1, shears)
   if not selected then return false, "No shears available: " .. select_error end
   local cut, cut_error = automata.digBlock()
+  while cut_error == "dig is on cooldown" do
+    sleep(0.1)
+    cut, cut_error = automata.digBlock()
+  end
   if not cut then return false, "Could not cut vine: " .. cut_error end
   local collect, collect_error = automata.collectItems()
   if not collect then return false, "Could not collect vine: " .. collect_error end