BillBodkin

tFarm

Aug 15th, 2018
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.04 KB | None | 0 0
  1. print("Epic tree farm")
  2.  
  3. function tree()
  4.     turtle.select(1)
  5.     turtle.dig()
  6.     turtle.forward()
  7.     turtle.digDown()
  8.     while turtle.detectUp() do
  9.         turtle.digUp()
  10.         turtle.up()
  11.     end
  12.     while true do
  13.         local success, data = turtle.inspectDown()
  14.         if success then
  15.             if data.name == "minecraft:dirt" then
  16.                 break
  17.             else
  18.                 turtle.digDown()
  19.                 turtle.down()
  20.             end
  21.         else
  22.             turtle.digDown()
  23.             turtle.down()
  24.         end
  25.     end
  26.     turtle.up()
  27. end
  28.  
  29. function plant()
  30.     for i=1,16,1 do
  31.         turtle.select(i)
  32.         local data = turtle.getItemDetail(i)
  33.         if data then
  34.             if data.name == "plants2:sapling_0" then
  35.                 turtle.placeDown()
  36.                 break
  37.             end
  38.         end
  39.     end
  40. end
  41.  
  42. function round()
  43.     while true do
  44.         local success, data = turtle.inspect()
  45.         if success then
  46.             if data.name == "plants2:log_0" then
  47.                 tree()
  48.             elseif data.name == "minecraft:stone" then
  49.                 turtle.turnLeft()
  50.                 turtle.forward()
  51.                 turtle.forward()
  52.                 turtle.turnLeft()
  53.             elseif data.name == "minecraft:stonebrick" then
  54.                 turtle.turnLeft()
  55.                 turtle.forward()
  56.                 turtle.forward()
  57.                 turtle.turnRight()
  58.                 turtle.forward()
  59.                 turtle.forward()
  60.                 turtle.turnLeft()
  61.                 turtle.turnLeft()
  62.                 return
  63.             else
  64.                 print("Unrecognised block: ", data.name)
  65.             end
  66.         end
  67.         plant()
  68.         turtle.forward()
  69.     end
  70. end
  71.  
  72. function empty()
  73.     for i=1,16,1 do
  74.         turtle.select(i)
  75.         local data = turtle.getItemDetail(i)
  76.         if data then
  77.             if data.name == "plants2:sapling_0" then
  78.                 turtle.turnLeft()
  79.                 turtle.drop(64)
  80.                 turtle.turnRight()
  81.             elseif data.name == "plants2:log_0" then
  82.                 turtle.dropDown(64)
  83.             else
  84.                 print("Unrecognised item in the bagging area: ", data.name)
  85.             end
  86.         end
  87.     end
  88. end
  89.  
  90. function fuel()
  91.     while turtle.getFuelLevel() < 1000 do
  92.         print("Need fuel")
  93.         turtle.turnRight()
  94.         turtle.suck(64)
  95.         for i=1,16,1 do
  96.             turtle.select(i)
  97.             turtle.refuel(64)
  98.         end
  99.         turtle.turnLeft()
  100.     end
  101. end
  102.  
  103. function saplings()
  104.     turtle.select(1)
  105.     turtle.turnLeft()
  106.     turtle.suck(64)
  107.     turtle.turnRight()
  108. end
  109.  
  110. fuel()
  111. saplings()
  112. round()
  113. empty()
Advertisement
Add Comment
Please, Sign In to add comment