zippy36jr

Nether highway

Dec 27th, 2021 (edited)
353
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. local args = {...}
  2.  
  3. local dist = tonumber(args[1])
  4.  
  5. local movementCount = 0
  6. local maxSlots = 16
  7. local curSlot = turtle.getSelectedSlot()
  8.  
  9. function dig()
  10.     turtle.digUp()
  11.     turtle.dig()
  12. end
  13.  
  14. function nextSlot()
  15.     if curSlot == maxSlots then
  16.         curSlot = 1
  17.     else
  18.         curSlot = curSlot + 1
  19.     end
  20.  
  21.     return curSlot
  22. end
  23.  
  24. function bridge()
  25.     if not turtle.detectDown() then
  26.         local ok, err = turtle.placeDown()
  27.  
  28.         if not ok then
  29.             turtle.select(nextSlot())
  30.  
  31.             bridge()
  32.         end
  33.     end
  34. end
  35.  
  36. function moveForward()
  37.     turtle.forward()
  38.     bridge()
  39.     movementCount = movementCount + 1
  40. end
  41.  
  42.  
  43. while movementCount < dist do
  44.  
  45.     if turtle.detect() or turtle.detectUp() then
  46.         dig()
  47.     else
  48.         moveForward()
  49.     end
  50. end
  51.  
Add Comment
Please, Sign In to add comment