Advertisement
GeoffAlexander

ClearArea

Oct 29th, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.29 KB | None | 0 0
  1. function turnAround()
  2.     turtle.turnLeft()
  3.     turtle.turnLeft()
  4. end
  5.  
  6. function sandDig()
  7.     while turtle.detect() do
  8.         turtle.dig()
  9.     end
  10.     while turtle.detectUp() do
  11.         turtle.digUp()
  12.     end
  13.     turtle.digDown()
  14. end
  15.  
  16. function forward(n) -- Forward and dig
  17.     for i=1,n do
  18.         sandDig()
  19.         turtle.forward()
  20.     end
  21. end
  22.  
  23. function down(n) -- Down n times
  24.     for i = 1,n do
  25.         turtle.down()
  26.     end
  27. end
  28.  
  29. function digL() -- Dig length
  30.     if l > 0 then
  31.         for i = 1,l-1 do
  32.             sandDig()
  33.             turtle.forward()
  34.         end
  35.     end
  36. end
  37.  
  38. function nextRow()
  39.     if count % 2 == 0 then -- Right for even number rows
  40.         turtle.turnRight()
  41.         sandDig()
  42.         turtle.forward()
  43.         turtle.turnRight()
  44.     else -- Left for odd number rows
  45.         turtle.turnLeft()
  46.         sandDig()
  47.         turtle.forward()
  48.         turtle.turnLeft()
  49.     end
  50.     count = count + 1
  51. end
  52.  
  53. function section()
  54.     for i = 1,w do
  55.         digL() -- Dig out length and move to next rows
  56.         if i < w then -- Won't start extra row at end
  57.             nextRow() -- Digs one whole section
  58.         end
  59.     end
  60. end
  61.  
  62. count = 1 -- For nextRow function
  63.  
  64. print("How far forward? (length)")
  65. l = tonumber(read()) -- Length
  66. print("How far left? (width)")
  67. w = tonumber(read()) -- Width
  68.  
  69. if h > 0 then
  70.     print("Here I go!")
  71.     goingUp()
  72. end
  73. if h > 0 then
  74.     print("Complete.")
  75.     down(h) -- Parks turtle in bottom corner
  76. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement