BioPrince

turtle world eater

Dec 26th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. -- pastebin get BaBEfuc2 miner
  2.    
  3. yLevel = 0
  4. i = 0
  5. block = "false"
  6. data = "false"
  7. height = 55
  8.  
  9. function bottom() --bottom out to find y level
  10.   while true do
  11.     block,data = turtle.digDown()
  12.       if data == "Unbreakable block detected" then
  13.         break
  14.       end
  15.     while turtle.dig() do
  16.     end
  17.     turtle.down()
  18.   end
  19. end
  20. -----------------------
  21. function empty() -- place enderchest and empty. this function is run after clear()
  22.   while turtle.dig() do
  23.     sleep(.2)
  24.   end
  25.   turtle.select(16)
  26.   turtle.place()
  27.   for i = 1, 14 do
  28.     turtle.select(i)
  29.     turtle.drop()
  30.   end
  31.   turtle.select(16)
  32.   turtle.dig()
  33.   turtle.select(1)
  34.   turtle.forward()
  35.   while turtle.dig() do
  36.     sleep(.2)
  37.   end
  38.   turtle.forward()
  39. end
  40. -----------------------
  41. function clear() -- check area for bedrock
  42.   for i = 1, 5 do
  43.   while turtle.dig() do
  44.     sleep(.2)
  45.   end
  46.   turtle.dig()
  47.   while turtle.digUp() do
  48.     sleep(.2)
  49.   end
  50.   turtle.up()
  51.   end
  52. end
  53. -----------------------
  54. function turtleRefuel()
  55.   if turtle.getFuelLevel() < 5000 then
  56.   for i=1,14 do
  57.     turtle.select(i)
  58.     turtle.refuel()
  59.     turtle.select(1)
  60.   end
  61.   end
  62. end
  63. -----------------------
  64. function lowFuel() -- checks for low fuel and waits if at top of loop
  65.   if turtle.getFuelLevel() < 200 then
  66.   local i = turtle.getItemCount(15)-1
  67.   turtle.select(15)
  68.   turtle.refuel(i)
  69.   turtle.select(1)
  70.   print("WARNING: Low Fuel")
  71.   if yLevel > height then
  72.     print("Waiting for fuel")
  73.     os.pullEvent("turtle_inventory")
  74.   end
  75.   end
  76. end
  77. ---------------------
  78. function self()
  79.   turtleRefuel()
  80.   lowFuel()
  81.   lowFuel()
  82. end
  83. --------------------
  84. function minerUp() -- bottom to top mining
  85.   for i=0,height do
  86.   while turtle.digUp() do
  87.     sleep(.2)
  88.   end
  89.   while turtle.dig() do
  90.     sleep(.2)
  91.   end
  92.   turtle.up()
  93.   end
  94. end
  95. -------------------
  96. function inventory() -- check for fuel and enderchest
  97.   print("fuel in slot 15")
  98.   print("enderchest in slot 16")
  99.   turtle.dig() --just in case it is placed before a restart
  100.   while turtle.getItemCount(16) == 0 do
  101.     os.pullEvent("turtle_inventory")
  102.   end
  103.   while turtle.getItemDetail(16).name ~= "EnderStorage:enderChest" do
  104.     print("ender chest in slot 16")
  105.     os.pullEvent("turtle_inventory")
  106.   end
  107. end
  108. --------------------
  109. -- Main function
  110. -- start with going to bedrock
  111.  
  112. inventory()
  113. bottom()
  114.   print("Reached Bedrock")
  115.   yLevel=0
  116. -- the turtle miner is now ready
  117.  
  118. while true do
  119.  
  120. clear()-- making room for chest
  121.   yLevel=5
  122. self()-- fuel check
  123. empty()-- place chest, empty, get chest, move into postion
  124.   print("Mining Up")
  125. bottom()
  126. minerUp()
  127. clear()-- making room for chest
  128.   yLevel=height+5
  129. self()-- fuel check
  130. empty()-- place chest, empty, get chest, move into postion
  131.   print("Mining Down")
  132. bottom() -- minerUp, just backwards
  133.  
  134. end
Advertisement
Add Comment
Please, Sign In to add comment