kabluey

Deweed

Apr 10th, 2021 (edited)
1,163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. print("Starting to clear area")
  2.  
  3. args = {...} --Get Aruguments Length Width Height
  4.  
  5. if #arg ~= 2 then
  6.         print("Please enter length and width")
  7.         return
  8. end
  9.  
  10. local length = tonumber(args[1])
  11. local width = tonumber(args[2])
  12.  
  13. function dig()
  14.         turtle.dig()
  15. end
  16.  
  17. function forward(n)
  18.         for x = 1, n do
  19.                 dig()
  20.                 s = turtle.forward()
  21.                 if not s == nil then
  22.                     print("Cannot move forward: " + s)
  23.                 end
  24.         end
  25. end
  26.  
  27. function right()
  28.         turtle.turnRight()
  29. end
  30.  
  31. function left()
  32.         turtle.turnLeft()
  33. end
  34.  
  35. function clearLayer()
  36.         for y = 1, width do
  37.                 forward(length - 1)
  38.  
  39.                 if y < width then
  40.                         if y % 2 == 1 then
  41.                                 right()
  42.                                 forward(1)
  43.                                 right()
  44.                         else
  45.                                 left()
  46.                                 forward(1)
  47.                                 left()
  48.                         end
  49.                 end
  50.         end
  51.  
  52.         if width % 2 == 1 then
  53.                 right()
  54.                 right()
  55.                 forward(length - 1)
  56.         end
  57.  
  58.         right()
  59.         forward(width - 1)
  60.         right()
  61. end
  62.  
  63. function clearArea()
  64.         clearLayer()
  65. end
  66.  
  67. while true do
  68.         clearArea()
  69. end
  70.  
  71. print("Area cleared")
  72.  
  73.  
Add Comment
Please, Sign In to add comment