Advertisement
Guest User

Farm

a guest
Aug 28th, 2014
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.51 KB | None | 0 0
  1. function failsafe()
  2.   turtle.select(1)
  3.   if not turtle.compareTo(14) then
  4.     print("No more Saplings")
  5.     print("Press any button to shutdown computer...")
  6.     os.pullEvent("key")
  7.     stop()
  8.   end
  9.   turtle.select(2)
  10.   if not turtle.compareTo(15) then
  11.     print("No more Bone Meal")
  12.     print("Press any button to shutdown computer...")
  13.     os.pullEvent("key")
  14.     stop()
  15.   end
  16.   turtle.select(3)
  17.   if not turtle.compareTo(16) then
  18.     print("No more fuel")
  19.     print("Press any button to shutdown computer...")
  20.     os.pullEvent("key")
  21.     stop()
  22.   end
  23. end
  24. function stop()
  25.   os.shutdown()
  26. end
  27. function chop() --Creates the function chop() for the wood chopping algorithm.
  28.   turtle.dig()
  29.   turtle.digUp()
  30.   turtle.up()
  31. end
  32. Bonemealcount = 20 --Sets the number of times it will place bonemeal on the sapling. I don't recommend changing this as this ensures the trees will grow and don't worry, it won't use bonemeal when the tree is already grown.
  33.  
  34. while true do
  35.   failsafe()
  36.   while turtle.getFuelLevel() <= 20 do --Checks if a refuel is needed and if it is needed it will refuel.
  37.     turtle.select(3)
  38.     turtle.refuel(1)
  39.   end
  40.   turtle.select(1) --Selects and places sapling.
  41.   turtle.place()
  42.   turtle.select(2) --Selects bonemeal.
  43.   for i = 1, Bonemealcount do --Places bonemeal on sapling.
  44.     turtle.place()
  45.   end
  46.   while turtle.detect() do --Wood chopping algorithm.
  47.     chop()
  48.   end
  49.   while not turtle.detectDown() do --Goes down until it reaches the ground.
  50.     turtle.down()
  51.   end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement