Advertisement
Lucified

TestProgram.lua

Jun 2nd, 2022
1,026
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1.  
  2. function detectLeft()
  3.     turtle.turnLeft()
  4.  
  5.     for i = 0, 20, 1 do
  6.         turtle.select(Block)
  7.         detected = turtle.compare()
  8.         if detected == true then turtle.turnRight() return true end
  9.     end
  10.     turtle.turnRight()
  11.     return false
  12. end
  13. function detectRight()
  14.     turtle.turnRight()
  15.  
  16.     for i = 0, 20, 1 do
  17.         turtle.select(Block)
  18.         detected = turtle.compare()
  19.         if detected == true then turtle.turnLeft() return true end
  20.     end
  21.     turtle.turnLeft()
  22.     return false
  23. end
  24.  
  25.  
  26. for i = 0, 20, 1 do
  27.  
  28.     if turtle.getFuelLevel() < 200 then
  29.         turtle.refuel(1)
  30.         print("Refueling")
  31.     end
  32.  
  33.     if detectLeft() == true then
  34.         turtle.turnLeft()
  35.         turtle.dig()
  36.         turtle.turnRight()
  37.     end
  38.     if detectRight() == true then
  39.         turtle.turnRight()
  40.         turtle.dig()
  41.         turtle.turnLeft()
  42.     end
  43.  
  44.  
  45.     turtle.forward()
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement