Advertisement
Ogan

Auto Feller

Feb 5th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.21 KB | None | 0 0
  1. --[[place some wood to slot 1
  2. any kind of fertilizer to slot 2 (I assume it will be compatible with 1.5 as it applies fertilizer until something grows.
  3. saplings to slot 3.
  4. incoming fertilizer chest to the right
  5. incoming sapling chest to the left
  6. outgoing wood chest to the back.
  7. this is intended to be used in FTB mod pack with wood golems collecting sulfur goo from torches and dropped saplings from the dead tree. you make a mob grinder for continuous fertilizer input in vanilla and have other turtles collect dropped sapplings. alternatively, you could have this turtle patrol around to collect them but it will increase fuel consumption. by default, it uses wood in slot 1 as fuel]]--
  8.  
  9. function cut() --cut a regular tree. will not seek all branches of a large tree. use a roof to limit growth
  10. turtle.select(1)
  11. local up=0
  12. while turtle.compare() do
  13.   up=up+1
  14.   turtle.dig()
  15.   turtle.digUp()
  16.  
  17.   while turtle.up()==false do
  18.   end --persistent movement. if cant move, try again
  19.  
  20. end
  21. for i=1,up,1 do
  22.   while turtle.down()==false do
  23.   end
  24. end
  25. end --end of cut
  26.  
  27.  
  28. while true do
  29.     c=turtle.getItemCount(2)--sulfur goo
  30.     if c<=2 then
  31.         turtle.turnRight()
  32.         turtle.suck()
  33.         turtle.turnLeft()
  34.     end
  35.  
  36.    
  37.     c=turtle.getItemCount(3)--sapling
  38.     if c<=2 then
  39.         turtle.turnLeft()
  40.         turtle.suck()
  41.         turtle.turnRight()
  42.     end
  43.    
  44.  
  45.     f=turtle.getFuelLevel()
  46.     if f<15 then
  47.         turtle.select(1)
  48.         turtle.refuel(1)
  49.         print("refuelling")
  50.     end
  51.  
  52.  
  53.     turtle.select(1)
  54.     if turtle.compare() then
  55.         print("tree detected. cutting...")
  56.         cut()
  57.         turtle.turnRight()
  58.         turtle.turnRight()
  59.         for i=4,16,1 do
  60.             turtle.select(i)
  61.             turtle.drop()
  62.         end
  63.         turtle.turnRight()
  64.         turtle.turnRight()
  65.         turtle.select(3)
  66.  
  67.         while turtle.place()==false do
  68.         end
  69.         print("placed sapling")
  70.         print("3 minute sleep")
  71.  
  72.         os.sleep(60*3)
  73.     end --end of cutting routine
  74.    
  75.     if turtle.detect()==false then
  76.         print("nothing detected. placing sapling")
  77.         turtle.select(3)
  78.         while turtle.place()==false do
  79.         end
  80.     end
  81.    
  82.     turtle.select(1)
  83.     while turtle.compare()==false and turtle.detect() do
  84.     print("sapling detected. using fertilizer")
  85.      turtle.select(2)
  86.      turtle.place()
  87.      turtle.select(1)
  88.     end
  89.  
  90. end --end of main loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement