TheKojent

flatten64

Jan 31st, 2013
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. --flattens a 64x64 area
  2. function forward()
  3.   while not turtle.forward() do
  4.     if not turtle.detect() then
  5.       turtle.attack()
  6.     else
  7.       turtle.dig()
  8.     end
  9.   end
  10. end
  11.  
  12. function floorCheck()
  13.   if not turtle.detectDown() then
  14.     turtle.select(1)
  15.     turtle.placeDown()
  16.   end
  17. end
  18.  
  19. function flat()
  20.   while turtle.detectUp() do
  21.     turtle.digUp()
  22.     turtle.Up()
  23.   end
  24.   while not turtle.detectDown() do
  25.     turtle.down()
  26.   end
  27. end
  28.  
  29. function flattenRow()
  30.   x = 0
  31.   flat()
  32.   while x < 63 do
  33.     forward()
  34.     floorCheck()
  35.     flat()
  36.     x = x + 1
  37.     turtle.suck()
  38.   end
  39. end
  40.  
  41. function returnH()
  42.   z = y - 1
  43.   turtle.turnLeft()
  44.   while z ~= 0 do
  45.     forward()
  46.     z = z - 1
  47.   end
  48.   turtle.turnLeft()
  49.   for i = 1,63 do
  50.     forward()
  51.   end
  52. end
  53.  
  54. function invDump()
  55.   i = 1
  56.   for 1,15 do
  57.     i = i + 1
  58.     turtle.select(i)
  59.     turtle.drop()
  60.   end
  61.   turtle.select(1)
  62.   turtle.dropUp()
  63.   turtle.suckUp()
  64. end
  65.  
  66. y = 0
  67. while y < 63 do
  68.   y = y + 1
  69.   flattenRow()
  70.   returnH()
  71.   invDump()
  72.   turtle.turnLeft()
  73.   r = y
  74.   while r ~= 0 do
  75.     forward()
  76.     r = r - 1
  77.   end
  78.   turtle.turnLeft()
  79. end
  80. flattenRow()
  81. returnH()
  82. invDump()
Advertisement
Add Comment
Please, Sign In to add comment