iconmaster

tunnel2

Apr 1st, 2013
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. args = {...}
  2. if #args < 2 then print("Usage: tunnel2 side len") os.exit() end
  3. side = args[1]
  4. len = tonumber(args[2])
  5. slot = 1
  6.  
  7. if side == "l" then
  8. sidef=function()
  9. turtle.turnLeft()
  10. turtle.place()
  11. turtle.turnRight()
  12. end
  13. elseif side == "r" then
  14. sidef=function()
  15. turtle.turnRight()
  16. turtle.place()
  17. turtle.turnLeft()
  18. end
  19. elseif side == "m" then
  20. sidef= function() end
  21. else
  22. print("ERROR: Side must be l, r, or m!")
  23. os.exit()
  24. end
  25.  
  26. function check()
  27. if turtle.getItemCount(slot) == 0 then
  28. slot = slot + 1
  29. turtle.select(slot)
  30. end
  31. end
  32.  
  33. function dig()
  34. while turtle.detect() do
  35. turtle.dig()
  36. sleep(.1)
  37. end
  38. end
  39.  
  40. for i=1,len do
  41. check()
  42. dig()
  43. turtle.placeDown()
  44. sidef()
  45. turtle.up()
  46. check()
  47. dig()
  48. sidef()
  49. turtle.up()
  50. check()
  51. dig()
  52. turtle.placeUp()
  53. sidef()
  54. turtle.down()
  55. turtle.down()
  56. turtle.forward()
  57. end
  58.  
  59. for i=1,len do
  60. turtle.back()
  61. end
Advertisement
Add Comment
Please, Sign In to add comment