Advertisement
R167

Turtle Program: Automatic Farm

Nov 28th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- Auto mob farm
  2. -- WInston Durand
  3.  
  4. canOutput = false
  5. count = 0
  6.  
  7. function farm()
  8.   canOutput = true
  9.   while true do
  10.     turtle.select(1)
  11.     turtle.suck()
  12.     if turtle.attack() then
  13.       turtle.suck()
  14.       if turtle.getItemCount(16) > 0 then
  15.         canOutput = false
  16.         turtle.turnLeft()
  17.         for i = 1, 16 do
  18.           count = count + turtle.getItemCount(i)
  19.           turtle.select(i)
  20.           turtle.drop()
  21.         end
  22.         turtle.select(1)
  23.         turtle.turnRight()
  24.         canOutput= true
  25.         print(tostring(count) .. " items farmed")
  26.       end
  27.     else
  28.       sleep(0.1)
  29.     end
  30.   end
  31. end
  32.  
  33. function timer()
  34.   while true do
  35.     while not canOutput do
  36.       sleep(0.1)
  37.     end
  38.     redstone.setOutput("back", true)
  39.     sleep(0.5)
  40.     redstone.setOutput("back", false)
  41.     while not canOutput do
  42.       sleep(0.1)
  43.     end
  44.     sleep(60)
  45.   end
  46. end
  47.  
  48. parallel.waitForAll(farm, timer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement