Advertisement
shirkit

turtle quarry

May 20th, 2013
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. -- deploy the miner
  2. function deploy()
  3.     turtle.select(16)
  4.     turtle.place()
  5.     turtle.select(1)
  6. end
  7.  
  8. -- returns if something was dropped below this turtle
  9. function clearInv()
  10.     local something = false
  11.     for i = 1, 16 do
  12.         turtle.select(i)
  13.         something = something or turtle.getItemCount(i) > 0
  14.         turtle.dropDown()
  15.     end
  16.     return something
  17. end
  18.  
  19. -- retrieves the miner in the front
  20. function getMiner()
  21.     turtle.select(16)
  22.     turtle.dropDown()
  23.     turtle.dig()
  24.     turtle.select(1)
  25. end
  26.  
  27. redstone.setOutput("back", false)
  28.  
  29. while true do
  30.     -- wait until we find a redstone signal
  31.     -- and maintain this redstone signal until we are done
  32.     if redstone.getInput("back") == true then
  33.         redstone.setOutput("back", true)
  34.         deploy()
  35.         sleep(5)
  36.         -- wait until we deployed something
  37.         while clearInv() == false do
  38.             sleep(math.random(5))
  39.         end
  40.         while clearInv() == true do
  41.             sleep(4 + math.random() * 5)
  42.         end
  43.         clearInv()
  44.         getMiner()
  45.         redstone.setOutput("back", false)
  46.        
  47.         while redstone.getInput("back") == true do
  48.             sleep(2)
  49.         end
  50.     else
  51.         sleep(2)
  52.     end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement