Clem105

Tree Farm

Aug 30th, 2015
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1. --tree farm propramm
  2. FuelSlot = 16
  3. SappSlot = 1
  4. TurnRightBlock = {"chisel:sandstone_scribbles" ,10 }
  5. TurnLeftBlock = {"chisel:sandstone" ,10 }
  6. KeepStraightBlock = {"chisel:sandstone" ,8 }
  7. RechargeBlock = {"chisel:sandstone" ,15 }
  8.  
  9. function checkBlock()
  10.     t,Data = turtle.inspectDown()
  11.     if t == false then
  12.         os.shutdown()
  13.     else
  14.         if Data["name"] == TurnLeftBlock[1] and Data["metadata"] == TurnLeftBlock[2] then
  15.             turtle.turnRight()
  16.             checkWood()
  17.             turtle.turnLeft()
  18.             checkWood()
  19.             turtle.turnLeft()
  20.             turtle.forward()
  21.         elseif Data["name"] == TurnRightBlock[1] and Data["metadata"] == TurnRightBlock[2] then
  22.             turtle.turnLeft()
  23.             checkWood()
  24.             turtle.turnRight()
  25.             checkWood()
  26.             turtle.turnRight()
  27.             turtle.forward()
  28.         elseif Data["name"] == KeepStraightBlock[1] and Data["metadata"] == KeepStraightBlock[2] then
  29.             turtle.turnLeft()
  30.             checkWood()
  31.             turtle.turnRight()
  32.             turtle.turnRight()
  33.             checkWood()
  34.             turtle.turnLeft()
  35.             turtle.forward()
  36.         elseif  Data["name"] == RechargeBlock[1] and Data["metadata"] == RechargeBlock[2] then
  37.             turtle.turnLeft()
  38.             DumpStuff()
  39.             turtle.turnRight()
  40.             turtle.turnRight()
  41.             FuelRequest()
  42.             turtle.turnLeft()
  43.             turtle.forward()
  44.         end
  45.     end
  46. end
  47.  
  48. function checkWood()
  49.     p,cData = turtle.inspect()
  50.     if p == false then
  51.         turtle.select(SappSlot)
  52.         turtle.place()
  53.     elseif cData["name"] == "minecraft:log" then
  54.         turtle.dig()
  55.         turtle.forward()
  56.         a,b = turtle.inspectUp()
  57.         local y=0
  58.         while b["name"] == "minecraft:log" do
  59.             turtle.digUp()
  60.             turtle.up()
  61.             a,b = turtle.inspectUp()
  62.             y= y+1
  63.         end
  64.         for n = 1,y do
  65.             turtle.down()
  66.         end
  67.         turtle.forward()
  68.     end
  69. end
  70.  
  71. function DumpStuff()
  72.     for i=1,16 do
  73.         if i ~= SappSlot or i ~= FuelSlot then
  74.             turtle.select(i)
  75.             turtle.drop()
  76.         end
  77.     end
  78. end
  79.  
  80. function FuelRequest()
  81.     c = turtle.getItemCount(FuelSlot)
  82.     turtle.select(FuelSlot)
  83.     turtle.suck(64-c)
  84. end
  85.  
  86. function Refuel()
  87.     if turtle.getFuelLevel() < 10 then
  88.         turtle.select(FuelSlot)
  89.         turtle.refuel(1)
  90.     end
  91. end
  92.  
  93. while true do
  94.     checkBlock()
  95.     Refuel()
  96. end
Advertisement
Add Comment
Please, Sign In to add comment