Advertisement
JMANN2400

ClearTrees

May 12th, 2020
995
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. print("+-------------------------------------+")
  2. print("| Area length = ?                   |")
  3. print("+-------------------------------------+")
  4. lenx = tonumber(read())
  5. print("+-------------------------------------+")
  6. print("| Area width = ?                   |")
  7. print("+-------------------------------------+")
  8. leny = tonumber(read())
  9.  
  10. function fellTree()
  11.     if (turtle.detect()) then
  12.         turtle.dig()
  13.         turtle.digUp()
  14.         turtle.up()
  15.         fellTree()
  16.         turtle.down()
  17.     end
  18. end
  19.  
  20. for x = 0, lenx, 1 do
  21.     for y = 0, leny, 1 do
  22.         success, id = turtle.inspect()
  23.         if success then
  24.             if string.match(id.name, "log") then
  25.                 fellTree()
  26.             end
  27.         end
  28.         while (turtle.detect()) do
  29.             turtle.digUp()
  30.             turtle.up()
  31.         end
  32.         turtle.forward()
  33.         while (not turtle.detectDown()) do
  34.             turtle.digDown()
  35.             turtle.down()
  36.         end
  37.     end
  38.     turtle.turnRight()
  39.     turtle.turnRight()
  40.     for y = 0, leny, 1 do
  41.         while (turtle.detect()) do
  42.             turtle.digUp()
  43.             turtle.up()
  44.         end
  45.         turtle.forward()
  46.         while (not turtle.detectDown()) do
  47.             turtle.digDown()
  48.             turtle.down()
  49.         end
  50.     end
  51.     turtle.turnLeft()
  52.     while (turtle.detect()) do
  53.         turtle.digUp()
  54.         turtle.up()
  55.     end
  56.     turtle.forward()
  57.     while (not turtle.detectDown()) do
  58.         turtle.digDown()
  59.         turtle.down()
  60.     end
  61.     turtle.turnLeft()
  62. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement