Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. function refuel()
  2. if turtle.getFuelLevel() < 1000 then
  3. turtle.select(2)
  4. turtle.refuel(10)
  5. end
  6. end
  7.  
  8. function torch()
  9. turtle.turnLeft()
  10. turtle.turnLeft()
  11. turtle.select(1)
  12. if turtle.getItemCount(1) > 1 then turtle.place() end
  13. turtle.turnLeft()
  14. turtle.turnLeft()
  15. end
  16.  
  17. function tunnel(l)
  18. local light = 0
  19. for i=1, l do
  20. refuel()
  21. while turtle.detect() do turtle.dig() end
  22. turtle.forward()
  23. if i == 1 then torch() end
  24. light = (light + 1)
  25. if light >= 13 then torch() light = 0 end
  26. while turtle.detectUp() do turtle.digUp() end
  27. turtle.select(3)
  28. turtle.placeDown()
  29.  
  30. end
  31. end
  32.  
  33. function turn(direction)
  34. if direction then turtle.turnLeft() end
  35. if not direction then turtle.turnRight() end
  36. tunnel(4)
  37. if direction then turtle.turnLeft() end
  38. if not direction then turtle.turnRight() end
  39. end
  40.  
  41.  
  42.  
  43.  
  44. function restock()
  45. turtle.dig()
  46. turtle.select(4)
  47. turtle.place()
  48. turtle.select(5)
  49. turtle.placeUp()
  50. for i=5, 16 do turtle.select(i) turtle.drop() end
  51. turtle.select(1)
  52. turtle.suckUp(turtle.getItemSpace(1))
  53. turtle.select(4)
  54. turtle.dig()
  55. turtle.select(5)
  56. turtle.digUp()
  57. turtle.select(1)
  58. turtle.place()
  59. end
  60.  
  61. args = {...}
  62. local length = args[1]
  63. if length == nil then print("Error Invalid Argument. ex: Dig (length) [left:right] [width] [r]") error() end
  64. local d = args[2]
  65. local direct = false
  66. if d == "left" then direct = true end
  67. local rows = args[3]
  68. if rows == nil then rows = 1 end
  69. local dump = args[4]
  70.  
  71. print(" Please add:")
  72. print("torches to Slot 1")
  73. print("fuel to slot 2")
  74. print("cobble to slot 3")
  75. if dump == "r" then print("Drop off chest to slot 4 and optionally a chest of torches to slot 5") end
  76. print("Press enter to continue.")
  77. read("*")
  78. term.clear()
  79. term.setCursorPos(1,1)
  80.  
  81. while true do
  82.  
  83. for i=1, rows do
  84. tunnel(length)
  85. turn(direct)
  86. direct = not direct
  87. tunnel(length)
  88. if dump == "r" then restock() end
  89. turn(direct)
  90. direct = not direct
  91. end
  92.  
  93. print("Press enter to continue.")
  94. read("*")
  95. term.clear()
  96. term.setCursorPos(1,1)
  97. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement