Advertisement
Ezteyh

3x3

Jun 14th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. print("longueur : ")
  2. local length = io.read()
  3.  
  4. -- Function Definitions --
  5. local function digVerticalLine()
  6.   while turtle.detect() do
  7.     turtle.dig()
  8.   end
  9.   turtle.forward()
  10.   while turtle.detectUp() do
  11.     turtle.digUp()
  12.     os.sleep(0.5)
  13.   end
  14.   turtle.digDown()
  15. end
  16.  
  17. local function turnAround()
  18.   turtle.turnRight()
  19.   turtle.turnRight()
  20. end
  21.  
  22. local function checkForHoles()
  23.   turtle.down()
  24.   if not turtle.detectDown() then
  25.     turtle.select(2)
  26.     turtle.placeDown()
  27.   end
  28.   turtle.up()
  29. end
  30.  
  31. local function digIntoWall()
  32.   digVerticalLine()
  33.   checkForHoles()
  34.   turtle.turnLeft()
  35.   digVerticalLine()
  36.   checkForHoles()
  37.   turnAround()
  38.   turtle.forward()
  39.   digVerticalLine()
  40.   checkForHoles()
  41.   turnAround()
  42.   turtle.forward()
  43.   turtle.turnRight()
  44. end
  45.  
  46. -- Program --
  47. turtle.up()
  48. for i=0, length - 1 do
  49.   digIntoWall()
  50.   if i % 5 == 0 then
  51.     turtle.select(1)
  52.     turtle.placeDown()
  53.   end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement