Advertisement
Guest User

Flatten

a guest
Jan 18th, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. -- Vars
  2. local tArgs = { ... }
  3. local togo = tonumber(tArgs[1])
  4. local width = tonumber(tArgs[2])
  5. togo = togo or 1
  6. width = width or togo
  7.  
  8.  
  9. -- Functions
  10.  
  11.  
  12. function upuntil()
  13.  local upc = 0
  14.  for u = 1, 8 do
  15.   repeat
  16.    turtle.digUp()
  17.    if turtle.up() then
  18.     upc = upc + 1
  19.    end
  20.    sleep(0.25)
  21.   until turtle.detectUp() == false
  22.  end
  23.  for dc = 1, upc do
  24.   turtle.down()
  25.  end
  26. end
  27.  
  28. function turnaround()
  29.   turtle.turnRight()
  30.   turtle.turnRight()
  31. end
  32.  
  33. -- Main Script
  34. for i = 1, width do
  35.  for j = 1, togo do
  36.   if turtle.detect() then
  37.    repeat
  38.     turtle.dig()
  39.     sleep(0.5)
  40.    until turtle.detect() == false
  41.    turtle.forward()
  42.    upuntil()
  43.   else
  44.    turtle.forward()
  45.    upuntil()
  46.   end
  47.  end
  48.  turnaround()
  49.  for j = 1, togo do
  50.   turtle.forward()
  51.  end
  52.  turtle.turnLeft()
  53.  if turtle.detect() then
  54.   repeat
  55.    turtle.dig()
  56.    sleep(0.5)
  57.   until turtle.detect() == false
  58.  end
  59.  turtle.forward()
  60.  turtle.turnLeft()
  61. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement