Advertisement
bryceio

Computercraft Tree Farm

Aug 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. i = 0
  2. y = 0
  3.  
  4. function turnRight(times)
  5.   repeat
  6.     turtle.turnRight()
  7.     i = i + 1
  8.   until i == times
  9.   i = 0
  10. end
  11.  
  12. function forward(times)
  13.   repeat
  14.     turtle.forward()
  15.     i = i + 1
  16.   until i == times
  17.   i = 0
  18. end
  19.  
  20. function itemdrop()
  21.   if y > 0 then
  22.     repeat
  23.       if turtle.down() == true then
  24.         y = y - 1
  25.       else
  26.         turtle.digDown()
  27.       end
  28.     until y == 0
  29.   end
  30.     turnRight(2)
  31.     forward(3)
  32.     i = 1
  33.     repeat
  34.       turtle.select(i)
  35.       items = turtle.getItemCount(i)
  36.       if items > 0 then
  37.         repeat
  38.           turtle.drop()
  39.           items = items - 1
  40.         until items == 0
  41.       end
  42.       i = i + 1
  43.     until i == 16
  44.     i = 0
  45.     turnRight(2)
  46.     forward(3)
  47. end
  48.  
  49. while true do
  50. if turtle.detect() == true then  
  51.   boo, block = turtle.inspect()
  52.   if block.name == "minecraft:log" then
  53.     turtle.dig()
  54.     turtle.digUp()
  55.     turtle.up()
  56.     y = y + 1
  57.   elseif block.name == "minecraft:sapling" then
  58.     fuel = turtle.getFuelLevel()
  59.     if fuel < 50 then
  60.       turnRight(2)
  61.       forward(3)
  62.       turnRight(1)
  63.       forward(1)
  64.       turtle.select(15)
  65.       repeat
  66.         turtle.suckDown()
  67.         turtle.refuel()
  68.         i = i + 1
  69.       until i == 5
  70.       i = 0
  71.       turnRight(2)
  72.       forward(1)
  73.       turnRight(3)
  74.       forward(3)
  75.     end
  76.     sleep(30)
  77.   else
  78.     itemdrop()
  79.   end
  80. else
  81.     if turtle.detectDown() == false then
  82.         turtle.up()
  83.         repeat
  84.             suc, block = turtle.inspect()
  85.             turtle.dig()
  86.             turtle.digUp()
  87.             turtle.up()
  88.         until suc == false
  89.         repeat
  90.             turtle.down()
  91.         until turtle.detectDown() == true
  92.         y = 0
  93.         itemdrop()
  94.     else
  95.         turtle.select(16)
  96.         turtle.place()
  97.     end
  98. end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement