Advertisement
Houshalter

ComputerCraft Flatten Area Script

Dec 19th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. local sizex, sizey, right = ...
  2. local sizex = tonumber(sizex or 50)
  3. local sizey = tonumber(sizey or 50)
  4.  
  5. function digForward()
  6.     while not turtle.forward() do
  7.         turtle.dig()
  8.     end
  9. end
  10.  
  11. function match(s)
  12.     s = s:lower()
  13.     local a = false
  14.     for i, p in ipairs(blocks) do
  15.         a = a or string.find(s, p:lower())
  16.     end
  17.     return a
  18. end
  19.  
  20. function clear()
  21.     local height = 0
  22.     while turtle.detectUp() or turtle.detect() do
  23.         if turtle.detectUp() then turtle.digUp() end
  24.         if turtle.detect() then turtle.dig() end
  25.         if turtle.up() then
  26.             height = height + 1
  27.         end
  28.     end
  29.     digForward()
  30.     digForward()
  31.     while turtle.detectUp() or turtle.detect() do
  32.         if turtle.detectUp() then turtle.digUp() end
  33.         if turtle.up() then
  34.             height = height + 1
  35.         end
  36.     end
  37.     for i = 1, height do
  38.         if turtle.detect() then turtle.dig() end
  39.         while not turtle.down() do turtle.digDown() end
  40.     end
  41.     digForward()
  42. end
  43.  
  44. turtle.select(1)
  45. for x = 1, sizex do
  46.     for y = 1, math.ceil(sizey/4) do
  47.         --[[local a, b = turtle.inspectDown()
  48.         if a and not (b.name:lower():find('dirt') or b.name:lower():find('grass')) then
  49.             turtle.digDown()
  50.         end
  51.         if ((not turtle.detectDown()) and (turtle.getItemCount(1) > 1)) then
  52.             turtle.placeDown()
  53.         end]]
  54.         clear()
  55.         digForward()
  56.     end
  57.     if right then
  58.         turtle.turnRight()
  59.         digForward()
  60.         turtle.turnRight()
  61.     else
  62.         turtle.turnLeft()
  63.         digForward()
  64.         turtle.turnLeft()
  65.     end
  66.     right = not right
  67.     digForward()
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement