Advertisement
Captain_Admiral

MiningTurtle

Mar 25th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. compass=peripheral.wrap("right")
  2. local start = true
  3.  
  4. --Config
  5. local space = 10
  6. local directions = 0
  7.  
  8. --Inventory:
  9. --Fuel,#,#,#
  10. --#,#,#,#
  11. --#,#,#,#
  12. --#,#,Torches(optional),Ender Chest
  13.  
  14. --[[
  15. Type:
  16. PeripheralLeft - PickAxe
  17. PeripheralRight - Compass
  18. --]]
  19.  
  20.  
  21. while true do
  22.  
  23. function direction()
  24. if compass.getFacing() >= directions then
  25. return compass.getFacing() - directions
  26. else
  27. return compass.getFacing() + 4 - directions
  28. end
  29. end
  30.  
  31. function refuelSelf()
  32. if turtle.getFuelLevel()<500 then
  33. while turtle.getFuelLevel()<500 do
  34. for i=1,16,1 do
  35. turtle.select(i)
  36. turtle.refuel(1)
  37. turtle.select(1)
  38. end
  39. end
  40. end
  41. end
  42.  
  43. function fillChest()
  44. for i=2,14,1 do
  45. turtle.select(i)
  46. turtle.dropDown()
  47. end
  48. turtle.select(16)
  49. os.sleep(8)
  50. if turtle.getItemCount(16) > 0 then
  51. for i = 2, 14, 1 do
  52. if turtle.transferTo(i) then
  53. break
  54. end
  55. if i == 14 then
  56. os.terminate()
  57. end
  58. end
  59. end
  60. turtle.digDown()
  61. turtle.select(15)
  62. turtle.digUp()
  63. turtle.dig()
  64. turtle.place()
  65. turtle.select(1)
  66. end
  67.  
  68. function align()
  69. if direction()==0 then
  70. turtle.turnLeft()
  71. if not turtle.forward() then
  72. turtle.turnRight()
  73. turtle.turnRight()
  74. end
  75. elseif direction()==2 then
  76. os.terminate()
  77. end
  78. end
  79.  
  80. function turnAround()
  81. if direction()==3 then
  82. turtle.select(16)
  83. if turtle.getItemCount(16) > 1 then
  84. os.terminate()
  85. end
  86.  
  87. while not turtle.placeDown() do
  88. turtle.digDown()
  89. end
  90.  
  91. fillChest()
  92. turtle.turnRight()
  93. turtle.dig()
  94. while not turtle.forward() do
  95. turtle.dig()
  96. end
  97. turtle.digUp()
  98. turtle.digDown()
  99.  
  100. turtle.turnRight()
  101. elseif direction()==1 then
  102. turtle.select(16)
  103.  
  104. if turtle.getItemCount(16) > 1 then
  105. os.terminate()
  106. end
  107.  
  108. while not turtle.placeDown() do
  109. turtle.digDown()
  110. end
  111.  
  112. fillChest()
  113. turtle.turnLeft()
  114. turtle.dig()
  115. while not turtle.forward() do
  116. turtle.dig()
  117. end
  118. turtle.digUp()
  119. turtle.digDown()
  120.  
  121. turtle.turnLeft()
  122. else
  123. turtle.turnLeft()
  124. if not turtle.forward() then
  125. turtle.turnRight()
  126. turtle.turnRight()
  127. end
  128.  
  129. end
  130.  
  131.  
  132. end
  133.  
  134. --Startup
  135. if start == true then
  136. print("Hi! My name is Liam!")
  137. print("Job: Mining")
  138. print("")
  139. print("Inventory:")
  140. print("Fuel,#,#,#")
  141. print("#,#,#,#")
  142. print("#,#,#,#")
  143. print("#,#,Torches(optional),Ender Chest")
  144. print("")
  145.  
  146. turtle.turnLeft()
  147. turtle.turnLeft()
  148. while turtle.forward() do
  149. end
  150. turtle.turnRight()
  151. turtle.turnRight()
  152. start=false
  153. end
  154.  
  155.  
  156. --Main
  157.  
  158. align()
  159.  
  160. for i=0,space,1 do
  161. turtle.dig()
  162. turtle.digUp()
  163. turtle.digDown()
  164. while not turtle.forward() do
  165. turtle.dig()
  166. refuelSelf()
  167. end
  168. end
  169. turnAround()
  170.  
  171.  
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement