Advertisement
mikebald

Turtle_Fell

Apr 5th, 2014
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. -- Starting Position
  2. -- Saplings goes in bottom half
  3. -- Goes up 7 maximum
  4.  
  5. function CheckSapling()
  6.   if turtle.getItemCount(16) < 1 then
  7.     FillSapling()
  8.   end
  9.  
  10.   -- Check after fill
  11.   if turtle.getItemCount(16) < 1 then
  12.      return false
  13.   end
  14.  
  15.   return true
  16. end
  17.  
  18. function FillSapling()
  19.    for n=5,15 do
  20.      if turtle.getItemCount(n) > 1 then
  21.         turtle.select(n)
  22.         turtle.transferTo(16)
  23.      end
  24.    end
  25. end
  26.  
  27. function CheckGrown()
  28.  turtle.digUp()
  29.  turtle.up()
  30.  for n=1,4 do
  31.   turtle.select(16)
  32.   if not turtle.compare() then
  33.     FellTreeAndReturn()
  34.     turtle.select(1)
  35.     turtle.dropDown()
  36.     turtle.select(16)
  37.     turtle.place()
  38.   end
  39.   turtle.turnRight()
  40.  end
  41.  turtle.down()
  42. end
  43.  
  44. function FellTreeAndReturn()
  45.  turtle.dig()
  46.  turtle.forward()
  47.  for n=1,5 do
  48.    turtle.digUp()
  49.    turtle.up()
  50.  end
  51.  
  52.  for n=1,5 do
  53.    turtle.down()
  54.  end
  55.  
  56.  turtle.turnRight()
  57.  turtle.turnRight()
  58.  turtle.forward()
  59.  turtle.turnRight()
  60.  turtle.turnRight()
  61. end
  62.  
  63. -- Start of the program
  64.  
  65. while true do
  66.  term.clear()
  67.  term.setCursorPos(1,1)
  68.  term.write( "Fuel: "..turtle.getFuelLevel())
  69.  CheckGrown()
  70.  
  71.  -- Do the checks & sleep
  72.  if turtle.getFuelLevel() < 50 or not CheckSapling() then
  73.     os.reboot()
  74.  end
  75.  
  76.  os.sleep(60)
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement