Advertisement
Guest User

farm.lua

a guest
Feb 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.15 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()
  28.     turtle.dig()
  29.     turtle.digUp()
  30.     turtle.up()
  31. end
  32. Bonemealcount = 20
  33.  
  34. while true do
  35.     failsafe()
  36.     while turtle.getFuelLevel() <= 20 do
  37.         turtle.select(3)
  38.         turtle.refuel(1)
  39.     end
  40.     turtle.select(1)
  41.     turtle.place()
  42.     turtle.select(2)
  43.     for i = 1, Bonemealcount do
  44.         turtle.place()
  45.     end
  46.     while turtle.detect() do
  47.         chop()
  48.     end
  49.     while not turtle.detectDown() do
  50.         turtle.down()
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement