Advertisement
rharris31415

Untitled

Mar 31st, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. local size = {...}
  2. if size ~= 3 then
  3.   print("I need an x, y,")
  4.   print("and z coordinate.")
  5.   print("Try again.")
  6.   term.clear()
  7.   term.setCursorPos(1,1)
  8.   error()
  9. else
  10.   print("Digging a hole...")
  11. end
  12.  
  13. function move(count)
  14.   for z = 1, count do
  15.     turtle.forward()
  16.   end
  17. end
  18.  
  19. function next(length, width)
  20.   if width % 2 == 0 then
  21.     turtle.turnRight()
  22.     turtle.move(width - 1)
  23.     turtle.turnRight()
  24.   else
  25.     turtle.turnRight()
  26.     turtle.turnRight()
  27.     move(length - 1)
  28.     turtle.turnRight()
  29.     move(width - 1)
  30.     turtle.turnRight()
  31.   end
  32.   turtle.down()
  33. end
  34.  
  35. function home(depth)
  36.   for i = 1, depth do
  37.     turtle.up()
  38.   end
  39.   turtle.back()
  40.   print("Hole complete. :)")
  41. end
  42.  
  43. for i = 1, size[3] do
  44.   for j = 1, size[2] do
  45.     for k = 1, (size[1] - 1) do
  46.       turtle.digDown()
  47.       turtle.forward()
  48.     end
  49.     turtle.digDown()
  50.     if j == size[2] then
  51.       next(size[1], size[2])
  52.     elseif j % 2 == 0 then
  53.       turtle.turnLeft()
  54.       turtle.forward()
  55.       turtle.turnLeft()
  56.     else
  57.       turtle.turnRight()
  58.       turtle.forward()
  59.       turtle.turnRight()
  60.     end
  61.   end
  62. end
  63.  
  64. Home(size[3])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement