Guest User

Untitled

a guest
Jun 1st, 2013
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. -- Digs a 3x3 hole to a user specified depth. 99% guarenteed to not lose anything.
  2. -- requirements: 2 identical storage devices (chests, enderchests, diamond chests, ect), fuel, mining turtle.
  3.  
  4. local downs = 0
  5. local ups = 1
  6. local refuelcounts = 0
  7.  
  8. function threesquare() --mine a 3x3 square directly around the turtle
  9. turtle.turnLeft()
  10. turtle.dig()
  11. turtle.forward()
  12. turtle.turnRight()
  13. turtle.dig()
  14. turtle.forward()
  15. turtle.turnRight()
  16. turtle.dig()
  17. turtle.forward()
  18. turtle.dig()
  19. turtle.forward()
  20. turtle.turnRight()
  21. turtle.dig()
  22. turtle.forward()
  23. turtle.dig()
  24. turtle.forward()
  25. turtle.turnRight()
  26. turtle.dig()
  27. turtle.forward()
  28. turtle.dig()
  29. turtle.forward()
  30. turtle.turnRight()
  31. turtle.forward()
  32. turtle.turnRight()
  33. turtle.forward()
  34. turtle.turnLeft()
  35. depth()
  36. end
  37.  
  38. function refueltry (n) -- how many times have we tried to refuel
  39. n = n or 1
  40. refuelcounts = refuelcounts + n
  41. end
  42.  
  43. function refuel()
  44. while turtle.getFuelLevel() < 130 do --130 fuel allows to dig to bedrock from approximatley z=119.
  45. turtle.select(15) -- keep fuel of some kind in this slot
  46. turtle.refuel(1)
  47. turtle.select(1)
  48. refueltry() --keep track of how many times we've tried to refuel
  49. if refuelcounts > 30 then --The weakest fuel, sticks, has 5 fuel value. Filling from 0 to 130 is 26 sticks, if the counter reaches 30 it means we have no fuel.
  50. error("You must provide aditional fuel\n")
  51. break
  52. end
  53.  
  54. end
  55. end
  56.  
  57. function dropall() --drop all the shit we just collected
  58. turtle.select(1)
  59. turtle.drop()
  60. turtle.select(2)
  61. turtle.drop()
  62. turtle.select(3)
  63. turtle.drop()
  64. turtle.select(4)
  65. turtle.drop()
  66. turtle.select(5)
  67. turtle.drop()
  68. turtle.select(6)
  69. turtle.drop()
  70. turtle.select(7)
  71. turtle.drop()
  72. turtle.select(8)
  73. turtle.drop()
  74. turtle.select(9)
  75. turtle.drop()
  76. turtle.select(10)
  77. turtle.drop()
  78. turtle.select(11)
  79. turtle.drop()
  80. turtle.select(12)
  81. turtle.drop()
  82. turtle.select(13)
  83. turtle.drop()
  84. turtle.select(14)
  85. turtle.drop()
  86. turtle.select(1)
  87. end
  88.  
  89. function depth (n) -- how deep has the turtle gone
  90. n = n or 1
  91. downs = downs + n
  92. end
  93. function dive()
  94. for d=1,ups do
  95. turtle.digDown()
  96. turtle.down()
  97. end
  98. threesquare()
  99. end
  100. function surface() --however deep we went now we gotta go back up the same number of times
  101. for i=1,downs do
  102. turtle.up()
  103. end
  104. deeper()
  105. end
  106. function deeper (n)
  107. n = n or 1
  108. ups = ups + n
  109. end
  110. write("How Deep? ")
  111. local howdeep = io.read()
  112. for q=1,howdeep do
  113. refuel() -- if we don't refuel here the turtle will start diving where it's placed and then go haywire when told to go "back" where the chest is supposed to be
  114. refuelcounts = 0 -- set the refuel atempt counter back to 0 so it doesn't eff up subsequent refuelings.
  115. turtle.forward()
  116. turtle.forward()
  117. refuel()
  118. refuelcounts = 0
  119. dive() -- handles counting how far down we need to go/have gone, calls the 3x3 digging function.
  120. refuel()
  121. refuelcounts = 0
  122. surface()
  123. turtle.back()
  124. turtle.back()
  125. turtle.turnRight() --place some kind of storage (chest, enderchest, diamond chest, whatever) on the right side of the turtle where it starts.
  126. turtle.select(16) -- place the same kind of storage in slot 16
  127. local chestfound = turtle.compare() -- make sure we're at a chest so we don't dump stuff in lava or whatever, just in case we got off course.
  128. if chestfound == true then
  129. dropall()
  130. else
  131. error("missing deposit chest\n") -- 99% of the time this means you forgot to put a chest to the right of the turtle. 1% of the time there's actually an issue
  132. break
  133. end
  134. turtle.turnLeft()
  135. end
Advertisement
Add Comment
Please, Sign In to add comment