Advertisement
Guest User

treeFarm

a guest
Jul 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.43 KB | None | 0 0
  1. function chop()
  2.   turtle.dig()
  3.   turtle.forward()
  4.   while turtle.compareUp() do
  5.     turtle.digUp()
  6.     turtle.up()
  7.   end
  8.   while not turtle.detectDown() do
  9.     turtle.down()
  10.   end
  11. turtle.back()
  12. end
  13.  
  14. function dropWood()
  15.   turtle.back()
  16.   turtle.back()
  17.   turtle.turnRight()
  18.   turtle.select(1)
  19.   turtle.drop()
  20.   turtle.suck(1)
  21.   turtle.turnLeft()
  22.   turtle.forward()
  23.   turtle.forward()
  24. end
  25.  
  26. function suckSaplings()
  27.   turtle.back()
  28.   turtle.back()
  29.   turtle.turnLeft()
  30.   turtle.select(2)
  31.   turtle.suck(60)
  32.   turtle.turnRight()
  33.   turtle.forward()
  34.   turtle.forward()
  35. end
  36.  
  37. function suckFuel()
  38.   turtle.turnLeft()
  39.   turtle.forward()
  40.   turtle.forward()
  41.   turtle.select(4)
  42.   turtle.suck(60)
  43.   turtle.refuel()
  44.   turtle.back()
  45.   turtle.back()
  46.   turtle.turnRight()
  47. end
  48.  
  49. function suckBnMl()
  50.   turtle.turnRight()
  51.   turtle.forward()
  52.   turtle.forward()
  53.   turtle.select(3)
  54.   turtle.suck(60)
  55.   turtle.back()
  56.   turtle.back()
  57.   turtle.turnLeft()
  58. end
  59.  
  60. --Main Program
  61. for i = 1, 10 do
  62.   turtle.select(2)
  63.   turtle.place()
  64.   turtle.select(3)
  65.   turtle.place()
  66.   turtle.select(1)
  67.   repeat
  68.   until turtle.compare()
  69.   chop()
  70.   local w = turtle.getItemCount(1)
  71.   local s = turtle.getItemCount(2)
  72.   local f = turtle.getFuelLevel()
  73.   local b = turtle.getItemCount(3)
  74.   if w>56 then
  75.     dropWood()
  76.   end
  77.   if s<2 then
  78.     suckSaplings()
  79.   end
  80.   if f<100 then
  81.     suckFuel()
  82.   end
  83.   if b<2 then
  84.   suckBnMl()
  85.   end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement