grand_mind1

Turtle Tree Farm

May 26th, 2013
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.73 KB | None | 0 0
  1. inv = peripheral.wrap("right")
  2. height = 1
  3. saplings = 1
  4. bonemeal = 2
  5. local tArgs = {...}
  6. turtle.select(1)
  7.  
  8. local function getSaplings()
  9.   turtle.turnLeft()
  10.   inv.suckSneaky(0,64-turtle.getItemCount(saplings))
  11.   turtle.turnRight()
  12. end
  13.  
  14. local function getBonemeal()
  15.   turtle.turnRight()
  16.   turtle.select(bonemeal)
  17.   inv.suckSneaky(0,64-turtle.getItemCount(bonemeal))
  18.   turtle.turnLeft()
  19. end
  20.  
  21. local function plant()
  22.   turtle.place()
  23.   turtle.select(2)
  24.   turtle.place()
  25.   turtle.select(1)
  26. end
  27.  
  28. if tArgs[1] == nil then
  29.   tArgs[1] = 1
  30. end
  31.  
  32. for t = 1,tonumber(tArgs[1]) do
  33.   times = 0
  34.   if turtle.getItemCount(saplings) < 64 then
  35.     getSaplings()
  36.   end
  37.   if turtle.getItemCount(bonemeal) < 64 then
  38.     getBonemeal()
  39.   else
  40.     print("I don't need bonemeal")
  41.   end
  42.  
  43.   while times ~= 64 and turtle.getItemCount(saplings) > 0 and turtle.getItemCount(bonemeal) > 0  and turtle.getFuelLevel() > 800 do
  44.     for i = 1,4 do
  45.       turtle.forward()
  46.     end
  47.  
  48.     plant()
  49.     turtle.dig()
  50.     turtle.forward()
  51.  
  52.     while turtle.detectUp() do
  53.       turtle.digUp()
  54.       turtle.up()
  55.       height = height+1
  56.     end
  57.    
  58.     for i = 1,height do
  59.       turtle.down()
  60.     end
  61.     turtle.back()
  62.     sleep(10)
  63.     plant()
  64.     times = times+1
  65.     print(times)
  66.   end
  67.   for i = 1,4 do
  68.     turtle.back()
  69.   end
  70.   for i = 1,8 do
  71.     turtle.select(i)
  72.     if turtle.compareTo(16) then
  73.       turtle.dropDown()
  74.     else
  75.       print("Not wood!")
  76.       if turtle.compareTo(14) then
  77.         print("It's saplings!")
  78.         turtle.transferTo(1)
  79.      elseif turtle.compareTo(15) then
  80.        print("It's bonemeal!")
  81.        turtle.transferTo(2)
  82.       end
  83.     end
  84.   end
  85.   turtle.select(1)
  86.   print("Done with rotation:"..t)
  87. end
Advertisement
Add Comment
Please, Sign In to add comment