Advertisement
Chronno

Computercraft Turtle Tree Chopping

Mar 18th, 2013
1,061
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. -- Tree farm program
  2. -- Place fir, spruce, or birch saplings in slot 1
  3. -- (will work with oak, but if it grows a big oak tree the program will miss the branches)
  4. -- place bonemeal in slot 2
  5. -- call the program by typing the program name followed by the number of trees you want chopped down
  6. -- check me out at Http://www.youtube.com/chronnotrigg
  7.  
  8. local trees = {...}
  9.  
  10. function plantTree()
  11.         turtle.select(1)
  12.         turtle.place()
  13.         turtle.select(2)
  14.         turtle.place()
  15. end
  16.  
  17. function chopTree()
  18.         local p = 0
  19.     for i=0,128 do
  20.         turtle.select(3)
  21.         if turtle.compareUp() == true then
  22.             turtle.digUp()
  23.             turtle.up()
  24.             p = p + 1
  25.         else
  26.             break
  27.         end
  28.     end
  29.     for i=1,p do
  30.         turtle.down()
  31.     end
  32. end
  33.  
  34.     -- main
  35. if trees[1] == 0 then
  36.         print("argument must be 1 or larger")
  37.         return
  38. elseif tonumber(trees[1]) == nil then
  39.         trees = 1
  40. end
  41. for i=1,trees[1] do
  42.         plantTree()
  43.         turtle.dig()
  44.         turtle.forward()
  45.         chopTree()
  46.         turtle.back()
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement