Advertisement
kelm

droptunnel

May 17th, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. local args = {...}
  2.  
  3. if args[1] == nil then
  4.   print ("Specify the depth to tunnel and place ladders in the turtle's inventory slots, starting at 1.")
  5. end
  6.  
  7. function step()
  8.   while not turtle.forward() do
  9.     turtle.dig()
  10.   end
  11. end
  12.  
  13. function stepBack()
  14.   if not turtle.back() then
  15.     turtle.turnRight()
  16.     turtle.turnRight()
  17.     step()
  18.     turtle.turnRight()
  19.     turtle.turnRight()
  20.   end
  21. end
  22.  
  23. function stepUp()
  24.   while not turtle.up() do
  25.     turtle.digUp()
  26.   end
  27. end
  28.  
  29. function stepDown()
  30.   while not turtle.down() do
  31.     turtle.digDown()
  32.   end
  33. end
  34.  
  35. local depth = tonumber(args[1])
  36. local slot = 0
  37. local ladders = 0
  38.  
  39. for i = 0, depth, 1 do
  40.   if ladders < 1 then
  41.     slot = slot + 1
  42.     ladders = turtle.getItemCount(slot)
  43.     turtle.select(slot)
  44.   end
  45.   stepDown()
  46.   turtle.dig()
  47.   turtle.place()
  48.   ladders = ladders - 1
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement