Advertisement
bool15

quarry

Nov 2nd, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. --=======================================Standard Lbrary=====================================--
  2. function smartFuel()
  3. if turtle.getFuelLevel() <= 0 then
  4. onSlot = turtle.getSelectedSlot()
  5. while not turtle.refuel(1) do
  6.  
  7. onSlot = onSlot + 1
  8. if onSlot == 17 then
  9. onSlot = 1
  10. end
  11. turtle.select(onSlot)
  12. end
  13. end
  14. end
  15.  
  16. function smartFor()
  17. while not turtle.forward() do
  18. turtle.attack()
  19. turtle.dig()
  20. smartFuel()
  21. end
  22. end
  23.  
  24. function smartUp()
  25. while not turtle.up() do
  26. turtle.attackUp()
  27. turtle.digUp()
  28. smartFuel()
  29. end
  30. end
  31.  
  32. function smartDown()
  33. while not turtle.down() do
  34. turtle.attackDown()
  35. turtle.digDown()
  36. smartFuel()
  37. cleanse()
  38. end
  39. end
  40.  
  41. function smartMove(dir)
  42. if dir == -1 then
  43. turtle.turnLeft()
  44. smartFor()
  45. elseif dir == 1 then
  46. turtle.turnRight()
  47. smartFor()
  48. elseif dir == 2 then
  49. smartFor()
  50. elseif dir == -2 then
  51. turtle.turnRight()
  52. turtle.turnRight()
  53. smartFor()
  54. elseif dir == 3 then
  55. smartUp()
  56. elseif dir == -3 then
  57. smartDown()
  58. end
  59. end
  60. --=======================================Quarry Functions=====================================--
  61. --======inputVars======--
  62. function inputVars()
  63. print("Enter Approx. height")
  64. CHUNKS = tonumber(read())/4
  65. print("Enter approx. width")
  66. PITS = tonumber(read())/5
  67. print("Enter Dive (Amount to go down before starting)")
  68. DIVE = tonumber(read())
  69. print("Enter Depth")
  70. DEPTH = tonumber(read())
  71. coalEstimate = math.ceil(((((((6+(DEPTH*2))*CHUNKS)*2)*PITS)+(DIVE*2))/80)*1.1)
  72. print("This quarry will require approximately " .. tostring(coalEstimate) .. " coal to complete. Is what you entered correct? Enter 'N' to re enter input, or any other button to start quarry")
  73. if read() == "N" then
  74. inputVars()
  75. end
  76. end
  77.  
  78.  
  79.  
  80.  
  81. DEPTH = 1
  82. --how deep do I go before I start the quarry?
  83. DIVE = 0
  84.  
  85.  
  86. --which ores not to mine
  87. blackList = {"minecraft:stone","minecraft:grass","minecraft:dirt","minecraft:sand","minecraft:gravel","minecraft:sandstone","minecraft:cobblestone"}
  88. --copper, uran,yellorite,marble,tin,lead, alu, silver, quartz
  89. --======dump======--
  90. function dump()
  91. for x = 1,16 do
  92. itemData = turtle.getItemDetail(x)
  93. if itemData then
  94. if onBlackList(itemData.name) then
  95. turtle.select(x)
  96. turtle.drop()
  97. end
  98. end
  99. end
  100. end
  101. --======hasRoom======--
  102. --returns if no slot is empty
  103. function hasRoom()
  104. for x = 1,16 do
  105. if turtle.getItemCount(x) == 0 then
  106. return true
  107. end
  108. end
  109.  
  110. return false
  111. end
  112. --======onBlackList======--
  113. function onBlackList(target)
  114. for z = 0,table.getn(blackList) do
  115. if target == blackList[z] then
  116. return true
  117. end
  118. end
  119.  
  120. return false
  121. end
  122. --======smartComp======--
  123. function smartComp()
  124. local sucess, data = turtle.inspect()
  125. if sucess then
  126. if not onBlackList(data.name) then
  127. turtle.dig()
  128. end
  129. end
  130. end
  131. --=====dropAll======--
  132. --excludes slot 2, saved for fuel
  133. function dropAll()
  134. for c = 3, 16 do
  135. turtle.select(c)
  136. turtle.drop()
  137. end
  138. end
  139. --======Store======--
  140. function store()
  141. turtle.dig()
  142. turtle.select(1)
  143. turtle.place()
  144. dropAll()
  145. turtle.select(1)
  146. turtle.dig()
  147. end
  148. --======cleanse======--
  149. function cleanse()
  150. data = turtle.getItemDetail(16)
  151. if data then
  152. dump()
  153. --store()
  154. end
  155. end
  156. --======smartMine======--
  157. function smartMine(dir)
  158. smartMove(3*dir)
  159. smartComp()
  160. turtle.turnRight()
  161. smartComp()
  162. turtle.turnRight()
  163. smartComp()
  164. turtle.turnRight()
  165. smartComp()
  166. turtle.turnRight()
  167. end
  168. --======Scale======--
  169. --must be facing "east"
  170. function scale(dir)
  171.  
  172. for i = 0, DEPTH, 1 do
  173. if dir == -1 then
  174. smartMine(-1)
  175. elseif dir == 1 then
  176. smartMine(1)
  177. end
  178. end
  179. smartMove(1)
  180. smartMove(-1)
  181. smartMove(2)
  182. end
  183.  
  184. --======chunk(2 holes in the ground)======--
  185. function chunk()
  186. scale(-1)
  187. scale(1)
  188. end
  189. --======Slice(a line of some chunks)======--
  190. --1 is west, -1 is east
  191. function slice(dir)
  192. for j = 0,CHUNKS-1 do
  193. chunk()
  194. end
  195.  
  196. if dir == 1 then
  197. smartMove(-1)
  198. smartMove(2)
  199. smartMove(2)
  200. smartMove(-1)
  201. elseif dir == -1 then
  202. smartMove(1)
  203. smartMove(2)
  204. smartMove(1)
  205. end
  206.  
  207. end
  208.  
  209. --======goBack======--
  210. function goBack()
  211.  
  212. smartMove(1)
  213. for v = 1, (PITS*5)-1 do
  214. smartMove(2)
  215. end
  216. end
  217. --======pit(one or more slices)======--
  218. function pit()
  219. slice(1)
  220. slice(-1)
  221. end
  222.  
  223.  
  224. --===================Function Start========================-
  225. inputVars()
  226. for i = 1, DIVE do
  227. smartMove(-3)
  228. end
  229. for l = 1, PITS do
  230. pit()
  231. end
  232. goBack()
  233. for i = 1, DIVE do
  234. smartMove(3)
  235. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement