feline-dis

0.0.1

Apr 12th, 2022 (edited)
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | None | 0 0
  1. local INV_SIZE = 16;
  2. local DIG_LENGTH = 25;
  3.  
  4. function refuel() if turtle.getFuelLevel() < 5000 then turtle.refuel() end end
  5.  
  6. function digColumn()
  7.     turtle.dig()
  8.     print("Trying to move forward")
  9.     turtle.forward()
  10.     turtle.digDown()
  11.     turtle.digUp()
  12. end
  13.  
  14. function digTunnel()
  15.     for i = 0, DIG_LENGTH, 1 do
  16.         digColumn()
  17.     end
  18. end
  19.  
  20. function forward(squares) for i = 0, squares, 1 do turtle.forward() end end
  21.  
  22. function digSquare()
  23.     for i = 0, 4, 1 do
  24.         print("Digging tunnel")
  25.         digTunnel()
  26.         turtle.turnRight()
  27.     end
  28. end
  29.  
  30. function zigZag()
  31.     local nTunnels = math.floor(DIG_LENGTH / 3)
  32.     local direction = 'right'
  33.  
  34.     for i = 0, nTunnels, 1 do
  35.  
  36.         if direction == 'right' then
  37.             forward(3)
  38.             turtle.turnRight()
  39.             digTunnel()
  40.             turtle.turnLeft()
  41.  
  42.             direction = 'left'
  43.         end
  44.  
  45.         if direction == 'left' then
  46.             forward(3)
  47.             turtle.turnLeft()
  48.             digTunnel()
  49.             turtle.turnRight()
  50.  
  51.             direction = 'right'
  52.         end
  53.     end
  54.  
  55. end
  56.  
  57. function main()
  58.     print("Turtle:")
  59.     print(turtle)
  60.     print("------")
  61.     refuel()
  62.     digSquare()
  63.  
  64.     zigZag()
  65.  
  66. end
  67.  
  68. main()
  69.  
Add Comment
Please, Sign In to add comment