Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[ Running this script on a turtle with saplings in slot 1, Wood in slot 2  and a chest behind the turtle for the wood drop off point will create an automatic tree farm. combining this with a chest to the left of the turtle for sapling replenishment and chest to the right for coal replenishment will ensure a long running automated process.]]
  2.  
  3. -- This function lays saplings and applies bone-meal
  4. function plant()
  5.     turtle.select(1)                --selects sapling
  6.     turtle.place()                  --places sapling
  7.     turtle.suck()                   --picks up any saplings that have fallen
  8. end
  9.  
  10. -- This function cuts a column directly above the turtle and then returns to ground level
  11. function column()
  12.     while turtle.detectUp() == true do      --cut tree down
  13.         turtle.digUp()
  14.         turtle.up()
  15.         turtle.suck()               --picks up any saplings that have fallen
  16.     end
  17.     while turtle.detectDown() == false do       -- return to ground level
  18.         turtle.down()
  19.         turtle.suck()               --picks up any saplings that have fallen
  20.     end
  21. end
  22.  
  23. -- This function moves from start position, runs column and returns to start position
  24. function fell()
  25.     turtle.dig()                    --breaks bottom block of tree
  26.     turtle.forward()                --move into gap
  27.     column()                    --run column function
  28.     turtle.turnRight()              --return to start
  29.     turtle.turnRight()
  30.     turtle.forward()
  31. end
  32.  
  33. -- This function empties all collected wood into chest, checks sapling and fuel supplies and restocks
  34. function empty()
  35.     for j = 3, 16 do                -- empty slots 3 to 16 into chest
  36.         turtle.select(j)
  37.         turtle.drop()
  38.     end
  39.     turtle.turnLeft()
  40.     turtle.turnLeft()
  41.     if turtle.getItemCount(1) < 5 then      --replenish sapling stocks
  42.         turtle.turnLeft()
  43.         turtle.select(1)
  44.         turtle.suck()
  45.         turtle.turnRight()
  46.     end
  47. end
  48.  
  49. -- This function checks to see if the sapling has been fertilized into a full tree
  50. function compare()
  51.     turtle.select(2)
  52.     if turtle.compare() == true then
  53.         return true             -- false could indicate that there is no grown Baum
  54.     else
  55.         return false  
  56.     end
  57. end
  58.  
  59. -- This block triggers the appropriate functions in the correct order.
  60. repeat                          --start loop
  61.     plant()                     --plant and fertilize tree
  62.     turtle.digUp()
  63.     turtle.up()
  64.     repeat
  65.         if compare() == true then           --if tree has grown cut down tree
  66.             turtle.down()
  67.             fell()
  68.         else                        --if tree hasn't grown display error
  69.             sleep(10)
  70.             turtle.suck()
  71.             until 1 > 2
  72.     end
  73.     empty()                     --empty harvest and restock fuel and materials
  74. until 1 > 2                     -- always false creating infinite loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement