Enderlein

Turtle Modular Tunnel

Jun 18th, 2022 (edited)
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. function clearCol()
  2.     turtle.dig()
  3.     turtle.forward()
  4.     turtle.digUp()
  5.     turtle.digDown()
  6. end
  7.  
  8. function selectItem(query)
  9.     for slot = 1, 16, 1 do
  10.         turtle.select(slot)
  11.         if turtle.getItemDetail() then
  12.             if turtle.getItemDetail().name == query then
  13.                 return true
  14.             end
  15.  
  16.             if slot == 16 then
  17.                 return false
  18.             end
  19.         end
  20.     end
  21. end
  22.  
  23. function placeTorch()
  24.     currentSlot = turtle.getSelectedSlot()
  25.     if selectItem("minecraft:torch") then
  26.         turtle.placeDown()
  27.     end
  28.     turtle.select(currentSlot)
  29. end
  30.  
  31. TORCH_FREQ = 8
  32. DISTANCE = tonumber(arg[1])
  33.  
  34. for i = 0, DISTANCE, 1 do
  35.     clearCol()
  36.  
  37.     if i % TORCH_FREQ == 0 then
  38.         placeTorch()
  39.     end
  40.  
  41.     if turtle.getFuelLevel() < (DISTANCE - i) then
  42.         shell.run("refuel")
  43.     end
  44.  
  45. end
  46.  
Add Comment
Please, Sign In to add comment